Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
script = ~S"""
pub fun main(owner:String): String {
return owner
}
"""
{:ok, channel} = GRPC.Stub.connect("access.mainnet.nodes.onflow.org:9000")
request = Flow.Access.GetLatestBlockRequest.new()
{:ok, resp} = Flow.Access.AccessAPI.Stub.get_latest_block(channel, request)
height = resp.block.height
req = Flow.Access.GetEventsForHeightRangeRequest.new(start_height: height-25, end_height: height, type: "A.c1e4f4f4c4257510.Market.MomentPurchased")
{:ok, resp} = Flow.Access.AccessAPI.Stub.get_events_for_height_range(channel, req)
height = 12401572
address = "0x7b0aac240b2bacda" |> String.slice(2..-1) |> Base.decode16!(case: :mixed)
req = Flow.Access.ExecuteScriptAtLatestBlockRequest.new(script: script, arguments: [address])
{:ok, resp} = Flow.Access.AccessAPI.Stub.execute_script_at_latest_block(channel, req)
# # ERROR MESSAGE # #
** (MatchError) no match of right hand side value: {:error, %GRPC.RPCError{message: "3 errors occurred:%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-4ab025ab974e7ad7f344fbd16e5fbcb17fb8769fc8849b9d241ae518787695bd@execution-003.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script at block (80d37dd9548b838086ef2ca7f8f98ebbf75e867c0a269976520278585e127491): Execution failed:%0Aerror: invalid argument at index 0%0A--> 6d1ffa79a634d8c6d2db47579ea9063093f578c5fc31ef24d5544d2a0b971a91%0A%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-160241f88cbfaa0f361cf64adb0a1c9fc19dec1daf4b96550cd67b7a9fb26cd9@execution-002.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script at block (80d37dd9548b838086ef2ca7f8f98ebbf75e867c0a269976520278585e127491): Execution failed:%0Aerror: invalid argument at index 0%0A--> 6d1ffa79a634d8c6d2db47579ea9063093f578c5fc31ef24d5544d2a0b971a91%0A%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-0ca407c1da940952ebcc02283b60cd97c9a008e111a48ea6cf1ce8f36f1e0153@execution-004.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script at block (80d37dd9548b838086ef2ca7f8f98ebbf75e867c0a269976520278585e127491): Execution failed:%0Aerror: invalid argument at index 0%0A--> 6d1ffa79a634d8c6d2db47579ea9063093f578c5fc31ef24d5544d2a0b971a91%0A%0A%0A", status: 2}}
# # ERROR MESSAGE # #
req = Flow.Access.ExecuteScriptAtBlockHeightRequest.new(script: script, block_height: height, arguments: [address])
{:ok, resp} = Flow.Access.AccessAPI.Stub.execute_script_at_block_height(channel, req)
# # ERROR MESSAGE # #
** (MatchError) no match of right hand side value: {:error, %GRPC.RPCError{message: "3 errors occurred:%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-4ab025ab974e7ad7f344fbd16e5fbcb17fb8769fc8849b9d241ae518787695bd@execution-003.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-160241f88cbfaa0f361cf64adb0a1c9fc19dec1daf4b96550cd67b7a9fb26cd9@execution-002.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%09* rpc error: code = Internal desc = failed to execute the script on the execution node execution-9686399a8a5418a12e762cfaeff2ea348c2137f554560917760e0d47acf2cda4@execution-001.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%0A", status: 2}}
# # ERROR MESSAGE # #
req = Flow.Access.GetAccountAtBlockHeightRequest.new(block_height: height-1, address: address)
{:ok, reps} = Flow.Access.AccessAPI.Stub.get_account_at_block_height(channel, req)
# # ERROR MESSAGE # #
** (MatchError) no match of right hand side value: {:error, %GRPC.RPCError{message: "failed to get account from the execution node: 3 errors occurred:%0A%09* rpc error: code = Internal desc = failed to get account: failed to get account at block (3787e0dfe48445c5cd9ce4e9302aa68bec25975ba9e483ea31d433ee61d97f42): failed to read key exists on account 7b0aac240b2bacda: ledger returns unsuccessful: error getting register (exists) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%09* rpc error: code = Internal desc = failed to get account: failed to get account at block (3787e0dfe48445c5cd9ce4e9302aa68bec25975ba9e483ea31d433ee61d97f42): failed to read key exists on account 7b0aac240b2bacda: ledger returns unsuccessful: error getting register (exists) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%09* rpc error: code = Internal desc = failed to get account: failed to get account at block (3787e0dfe48445c5cd9ce4e9302aa68bec25975ba9e483ea31d433ee61d97f42): failed to read key exists on account 7b0aac240b2bacda: ledger returns unsuccessful: error getting register (exists) value at 796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a: trie with the given rootHash [796c77f7cba33ee6349f90648e23d19b8eae03f64e490f65e380090fff57713a] not found%0A%0A", status: 13}}
# # ERROR MESSAGE # #
r = Flow.Access.GetAccountAtLatestBlockRequest.new(address: address)
{:ok, asd} = Flow.Access.AccessAPI.Stub.get_account_at_latest_block(channel, r)
# # SUCCESS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment