Skip to content
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

Gas Relayer Contracts #26

Closed
wants to merge 3 commits into from
Closed

Gas Relayer Contracts #26

wants to merge 3 commits into from

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Apr 28, 2024

Providing contract interface for the methods required in this tutorial. I would have gone with the full ABI, but all the existing tooling seems to be failing.

Example Transaction Sequence
near contract call-function as-transaction nft.kagi.testnet storage_deposit json-args {} prepaid-gas '100.0 Tgas' attached-deposit '1 NEAR'

near contract call-function as-transaction nft.kagi.testnet mint json-args {} prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR'

near contract call-function as-transaction nft.kagi.testnet ckt_approve json-args '{"token_id":"118","account_id":"canhazgas.testnet","msg":""}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR'


near contract call-function as-transaction canhazgas.testnet get_paymasters json-args '{"chain_id": "97"}' prepaid-gas '100.000 TeraGas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

near contract call-function as-transaction canhazgas.testnet set_paymaster_nonce json-args '{"chain_id": "97","token_id": "1", "nonce": 0}' prepaid-gas '100.000 TeraGas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

near contract call-function as-transaction canhazgas.testnet create_transaction json-args '{"transaction_rlp_hex":"ee6180847735940085174876e800825208947f01d9b227593e033bf8d6fc86e634d27aa85568865af3107a400080c0","use_paymaster":true, "token_id": "118"}' prepaid-gas '100.000 TeraGas' attached-deposit '0.5 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send



near contract call-function as-transaction canhazgas.testnet sign_next json-args '{"id":"28"}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send
Result of two calls to sign_next
➜  near-ca git:(remove-BN) ✗ near contract call-function as-transaction canhazgas.testnet sign_next json-args '{"id":"30"}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

Unsigned transaction:

signer_id:    ethdenver2024.testnet
receiver_id:  canhazgas.testnet
actions:
   -- function call:      
                   method name:  sign_next
                   args:         {
                                   "id": "30"
                                 }
                   gas:          300.0 Tgas
                   deposit:      0 NEAR

Warning: no access keys found in keychain, trying legacy keychain

Your transaction was signed successfully.
Public key: ed25519:6dgg56VuH8j52gR6cVnXndLe3XibUZ95tn1gppHz2iML
Signature: ed25519:md3WV443u3CufJunDjnHUdunTo2Mm9utfPheuwQ4vz3CNdpa4jjBru93PyKcYaSMCPw1hEnXcU9eiMnFZtqWzjT
▹▹▸▹▹ Sending transaction ...                                                                                   --- Logs ---------------------------
Logs [canhazgas.testnet]:   No logs
Logs [nft.kagi.testnet]:   No logs
Logs [multichain-testnet-2.testnet]:
  sign: signer=ethdenver2024.testnet, payload=[100, 225, 156, 29, 227, 78, 149, 169, 87, 174, 88, 219, 199, 219, 195, 11, 69, 75, 228, 161, 140, 237, 217, 128, 116, 205, 69, 218, 65, 239, 244, 19], path="1,", key_version=0
  [176,212,57,165,17,245,140,218,107,17,118,135,192,47,79,162,211,166,34,199,106,126,225,238,77,94,162,121,222,127,69,45]
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=0)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=1)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=2)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=3)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=4)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=5)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature ready: ("02C8145A8A7AD2517F7BF590D533ECA3A3ABB98279315A9E549A16B9569B5DF862", "438DD8C86FD18CCBBCBFF6D941D238F0DDFE22A45E095597821895FBC7EE5FBC"), depth: 6
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [nft.kagi.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [canhazgas.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
--- Result -------------------------
"0x02f8726101847735940085174876e800825208940c0a71335cc50b821570f6f8b302b248d0e56ed4870eebe0b40e800080c080a0c8145a8a7ad2517f7bf590d533eca3a3abb98279315a9e549a16b9569b5df862a0438dd8c86fd18ccbbcbff6d941d238f0ddfe22a45e095597821895fbc7ee5fbc"
------------------------------------

The "sign_next" call to <canhazgas.testnet> on behalf of <ethdenver2024.testnet> succeeded.
Transaction ID: DiHnK7vTEVJrC5mnfqhDK8UpoMQGCPeCZhzfFTn9bcR6
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/DiHnK7vTEVJrC5mnfqhDK8UpoMQGCPeCZhzfFTn9bcR6




Here is your console command if you need to script it or re-run:
    near contract call-function as-transaction canhazgas.testnet sign_next json-args '{"id":"30"}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

➜  near-ca git:(remove-BN) ✗ near contract call-function as-transaction canhazgas.testnet sign_next json-args '{"id":"30"}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

Unsigned transaction:

signer_id:    ethdenver2024.testnet
receiver_id:  canhazgas.testnet
actions:
   -- function call:      
                   method name:  sign_next
                   args:         {
                                   "id": "30"
                                 }
                   gas:          300.0 Tgas
                   deposit:      0 NEAR

Warning: no access keys found in keychain, trying legacy keychain

Your transaction was signed successfully.
Public key: ed25519:6dgg56VuH8j52gR6cVnXndLe3XibUZ95tn1gppHz2iML
Signature: ed25519:4oJVbtsmdsmLV38G4Wiy9bXgTknH8MKQsppWvBcTaZLvEsiwSfGoSGa6hJ6ESAHrR6v4UXteAhcyzY9B961nWPZX
▹▹▹▸▹ Sending transaction ...                                                                                   --- Logs ---------------------------
Logs [canhazgas.testnet]:   No logs
Logs [nft.kagi.testnet]:   No logs
Logs [multichain-testnet-2.testnet]:
  sign: signer=ethdenver2024.testnet, payload=[49, 188, 252, 183, 195, 34, 38, 249, 198, 57, 159, 8, 26, 75, 85, 95, 211, 7, 213, 16, 141, 29, 175, 89, 250, 68, 80, 89, 64, 205, 146, 240], path="118,", key_version=0
  [183,179,6,105,120,159,190,245,243,139,214,0,233,34,128,62,189,94,180,62,33,7,202,105,138,78,231,137,35,17,248,141]
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=0)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=1)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=2)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=3)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=4)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=5)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=6)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature not ready yet (depth=7)
Logs [multichain-testnet-2.testnet]:
  sign_helper: signature ready: ("03B4A11B2ADD89EA5BCA5D86A81B88F48E3C84585599CF16A3995EED375FC2FF00", "59862D6A04038467689C5D94C9079906C0FD4B3D6132F8A8AD3B51199D170B25"), depth: 8
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [nft.kagi.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [ethdenver2024.testnet]:   No logs
Logs [canhazgas.testnet]:
  EVENT_JSON:{"standard":"x-gas-station","version":"0.1.0","event":"transaction_sequence_signed","data":{"id":"30","foreign_chain_id":"97","created_by_account_id":"ethdenver2024.testnet","signed_transactions":["0x02f8726101847735940085174876e800825208940c0a71335cc50b821570f6f8b302b248d0e56ed4870eebe0b40e800080c080a0c8145a8a7ad2517f7bf590d533eca3a3abb98279315a9e549a16b9569b5df862a0438dd8c86fd18ccbbcbff6d941d238f0ddfe22a45e095597821895fbc7ee5fbc","0x02f8716180847735940085174876e800825208947f01d9b227593e033bf8d6fc86e634d27aa85568865af3107a400080c001a0b4a11b2add89ea5bca5d86a81b88f48e3c84585599cf16a3995eed375fc2ff00a059862d6a04038467689c5d94c9079906c0fd4b3d6132f8a8ad3b51199d170b25"]}}
Logs [ethdenver2024.testnet]:   No logs
--- Result -------------------------
"0x02f8716180847735940085174876e800825208947f01d9b227593e033bf8d6fc86e634d27aa85568865af3107a400080c001a0b4a11b2add89ea5bca5d86a81b88f48e3c84585599cf16a3995eed375fc2ff00a059862d6a04038467689c5d94c9079906c0fd4b3d6132f8a8ad3b51199d170b25"
------------------------------------

The "sign_next" call to <canhazgas.testnet> on behalf of <ethdenver2024.testnet> succeeded.
Transaction ID: 2Pqn8PsP6toVna8SzyNdEMvHdEkT8ywNY1S9UHhxNCk8
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/2Pqn8PsP6toVna8SzyNdEMvHdEkT8ywNY1S9UHhxNCk8




Here is your console command if you need to script it or re-run:
    near contract call-function as-transaction canhazgas.testnet sign_next json-args '{"id":"30"}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as ethdenver2024.testnet network-config testnet sign-with-keychain send

Result of eth_sendRawTransaction
➜  $ curl https://bsc-testnet.public.blastapi.io \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x02f8726101847735940085174876e800825208940c0a71335cc50b821570f6f8b302b248d0e56ed4870eebe0b40e800080c080a0c8145a8a7ad2517f7bf590d533eca3a3abb98279315a9e549a16b9569b5df862a0438dd8c86fd18ccbbcbff6d941d238f0ddfe22a45e095597821895fbc7ee5fbc"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x01a9f2820422e58fd1b1a50371f8c5a6c94e62866526ede9f8df44308f6956e0"}

➜  $ ✗ curl https://bsc-testnet.public.blastapi.io \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x02f8716180847735940085174876e800825208947f01d9b227593e033bf8d6fc86e634d27aa85568865af3107a400080c001a0b4a11b2add89ea5bca5d86a81b88f48e3c84585599cf16a3995eed375fc2ff00a059862d6a04038467689c5d94c9079906c0fd4b3d6132f8a8ad3b51199d170b25"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x82ce8c158e12d0e019eab49d4a312cacdb4228fd6fed6c902deaf109276a056e"}

Note that the first of the two rawTxs is not yet mined... was this supposed to be the paymaster funding? Its weird.

Questions

  • So many near transactions! Will this get bundled?
    3 to kagi.nft
    5 to canhazgas get_paymasters, set_nonce, create_tx, sign_next (2x)

  • What is the intermediary transaction?
    never gets mined...

  • How to get ABIs?

@bh2smith
Copy link
Contributor Author

Progress here is being kept up to date in the issue: #64

This PR is stale, and will be closed in favour of waiting until that work or some plan has been finalized.

@bh2smith bh2smith closed this Jun 12, 2024
@bh2smith bh2smith deleted the gas-relayer branch June 12, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant