-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utility to get configured network #1367
Comments
I would go with script, something like: pub fun main(): String {
var networkCodeWords = {
"MAINNET": UInt64(0x0),
"TESTNET": UInt64(0x6834ba37b3980209),
"EMULATOR": UInt64(0x1cb159857af02018)
}
for network in networkCodeWords.keys{
if getAccount(Address(UInt64(0xe467b9dd11fa00df) ^ networkCodeWords[network]!)).balance>0.0 {
return network
}
}
return "UNKNOWN"
} |
Thanks @bluesign ! What addresses are you using in your example script? |
Those are network codewords, by xoring with 0xe467b9dd11fa00df you get the account at index 1. which is Service Account This depends on FVM behavior, though I don’t think it will change. ( just incase I cc @janezpodhostnik ) |
There is also simple network addressing. ( which is not covered here ) used in playground as 0x1 0x2 etc |
@huyndo @chasefleming We should also send the connected network as part of the |
@gregsantos @huyndo Send it in the Discovery API call to in |
FCL Scripts might rely on and import deployed contracts.
We need a reliable way to get configured access node network for use in importing
contracts conditionally based on this network.
There is an issue in the pipeline to add an endpoint to the configured access node which will return necessary info.
We should implement a temporary fix that can be used throughout the lib and replaced asap.
It can be based on the current pattern, which checks for
flow.network
in FCL config and throws if not set.It might include a call to a known account on a maininet (FLOW Token Address), and fall back to testnet if account doesn't exist.
The text was updated successfully, but these errors were encountered: