bridgedETH - NEP-141 fungible-token representation of ETH inside Near.
nETH - native ETH inside Near EVM.
| Version | Description | Status | Ethereum Connector Address | NEAR Connector Account |
|---|---|---|---|---|
| develop.aurora | NEAR testnet - Ropsten | Working | 0x4a8FfD609122b80E1da0d95e51a31667804eA890 | develop.aurora |
| aurora | NEAR testnet - Ropsten | Working | 0x9006a6D7d08A388Eeea0112cc1b6b6B15a4289AF | aurora |
-
Make sure you have installed npm.
-
Install NEAR CLI:
$ npm install -g near-cli. -
Install Yarn:
$ npm install --global yarn. -
Clone this repo, and run
$ cd eth-custodianand$ yarn install. -
Create an account in Metamask in Ropsten testnet.
-
Get some Ropsten ETH. For example using this faucet: https://faucet.ropsten.be/.
-
Create an account in NEAR TestNet: https://wallet.testnet.near.org/.
-
Make sure that you're working with the NEAR TestNet:
$ export NODE_ENV=testnet. -
Log in to the NEAR Wallet from the CLI:
$ near login. The browser should pop up and a NEAR Wallet should ask for a permission for adding a full access key.
-
Go to eth-custodian directory:
$ cd eth-custodian. -
(Optional) Update
scripts/json/ethereum-config.jsonwith the actual data on the addresses. -
Create
.envfile insideeth-custodiandirectory:$ touch .env. -
Add to the file your RPC endpoint (with or without API key):
$ echo "WEB3_RPC_ENDPOINT=YOUR_WEB3_RPC_ENDPOINT_HERE" >> .env
(Optional) RPC access can be easily gained from Alchemy. -
Add to the file Ropsten Private key:
$ echo "ROPSTEN_PRIVATE_KEY=YOUR_ROPSTEN_PRIVATE_KEY_HERE" >> .env -
Add path to the Near credentials (e.g. this usually will be at
/home/<YOUR_USER_NAME>/.near-credentialson Linux
and$HOME/.near-credentialson MacOS:
$ echo "NEAR_KEY_STORE_PATH=PATH_TO_YOUR_NEAR_CREDENTIALS_HERE" >> .env -
Compile Ethereum contracts with:
$ make compile
To get the balance of bridgedETH (NEP-141):
$ make near-ft-balance-of NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE>
To get the balance of nETH (native ETH in Aurora-EVM):
$ make near-ft-balance-of-eth NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE> ETH_ADDRESS=<ETH_ADDRESS_OF_ACCOUNT_IN_EVM_HERE>
-
Go to eth-custodian directory:
$ cd eth-custodian. -
Transfer ETH to EthCustodian. Send
depositToNeartransaction to EthCustodian contract. This will transferAMOUNT(wei) from your account and depositAMOUNT(wei) havingFEE(wei) toNEAR_RECIPIENTaccount on Near.
Run:$ make eth-deposit-to-near NEAR_RECIPIENT=<ACCOUNT_ID_OF_RECIPIENT_HERE> AMOUNT=<DEPOSIT_AMOUNT_HERE> FEE=<DEPOSIT_FEE_HERE>. -
Wait sufficiently long You need to wait for 3 confirmations for Ropsten blockchain. This is needed to achieve finality of Ropsten block, including locking transaction. The status of syncing of the bridge can be observed here. First metric (
near_bridge_eth2near_client_block_number) should become more than the height of a block with transaction from the step 2 at least by 3, for a successful finalization of the transfer. -
Finalize deposit to Near Call deposit in Near blockchain to finalize the deposit transaction with the given
TX_HASH. You can findTX_HASHin the output of the previous step. You will need to provide yourNEAR_ACCOUNTAccountId which will be used to relay the ETH proof to the Near blockchain to mint appropriate amount of bridgedETH for theNEAR_RECIPIENT(this parameter is optional here and only serves for verbose purposes to show the balance of the recipient before and after)
Run:$ make near-finalize-deposit-from-eth TX_HASH=<DEPOSIT_TX_HASH_HERE> NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE> NEAR_RECIPIENT=<RECIPIENT_HERE>
-
Go to eth-custodian directory:
$ cd eth-custodian. -
Begin withdraw Send a
withdrawtransaction to the bridgedETH contract to withdrawAMOUNTbridgedETH (wei) from theNEAR_ACCOUNTand transfer the appropriate amount of ETH (wei) toETH_RECIPIENT(Specify without '0x' prefix). During the execution, the contract will issue an execution outcome, which would be used during finalization step to contruct the proof for the EthCustodian in Ethereum.
Run:$ make near-withdraw-to-eth NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE> ETH_RECIPIENT=<ETH_ADDRESS_OF_RECIPIENT_HERE> AMOUNT=<WITHDRAW_AMOUNT_HERE> FEE=<WITHDRAW_FEE_HERE> -
Wait sufficiently long This approximately takes 10 minutes for the Ropsten bridge deployment. This is needed to relay NEAR block with the height higher than the block with transaction from previous step to Ethereum, plus wait a challenge period. The status of syncing of the bridge can be observed here. First metric
near_bridge_near2eth_client_heightshould become higher than the block height displayed in console during the previous step. -
Finalize withdraw to Eth Call withdraw in Near blockchain to finalize the deposit transaction with the given
RECEIPT_ID. You can findRECEIPT_IDin the output of the previous step. Send awithdrawtransaction to the EthCustodian contract. After bridge syncing we are able to prove the fact of withdrawal transaction on NEAR to the EthCustodian contract.
Run:$ make eth-finalize-withdraw-from-near RECEIPT_ID=<RECEIPT_ID_FROM_STEP_2_HERE> NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE>
-
Go to eth-custodian directory:
$ cd eth-custodian. -
Transfer ETH to EthCustodian. Send
depositToEVMtransaction to EthCustodian contract. This will transferAMOUNT(wei) from your account and depositAMOUNT(wei) havingFEE(wei) toNEAR_RECIPIENTaccount on Near.
Run:$ make eth-deposit-to-evm ETH_RECIPIENT=<ETH_ADDRESS_OF_RECIPIENT_IN_EVM_HERE> AMOUNT=<DEPOSIT_AMOUNT_HERE> FEE=<DEPOSIT_FEE_HERE>. -
Wait sufficiently long You need to wait for 3 confirmations for Ropsten blockchain. This is needed to achieve finality of Ropsten block, including locking transaction. The status of syncing of the bridge can be observed here. First metric (
near_bridge_eth2near_client_block_number) should become more than the height of a block with transaction from the step 2 at least by 3, for a successful finalization of the transfer. -
Finalize deposit to Near Call deposit in Near blockchain to finalize the deposit transaction with the given
TX_HASH. You can findTX_HASHin the output of the previous step. You will need to provide yourNEAR_ACCOUNTAccountId which will be used to relay the ETH proof to the Near blockchain to mint appropriate amount of bridgedETH for theNEAR_RECIPIENT(this parameter is optional here and only serves for verbose purposes to show the balance of the recipient before and after)
Run:$ make near-finalize-deposit-from-eth-to-evm TX_HASH=<DEPOSIT_TX_HASH_HERE> NEAR_ACCOUNT=<YOUR_NEAR_ACCOUNT_HERE> ETH_RECIPIENT=<ETH_RECIPIENT_HERE>
WIP
To deploy the contract, you need at least proverAddress and nearEvmAccount addresses to be configured in
ethereum-config.json prior to the deployment.
After that call:
$ make eth-deploy-contracts
As a result of the function call you will get the address of the freshly deployed EthCustodian that you can put in
your ethereum-config.json file in the ethConnectorAddress field.
After ethConnectorAddress is set, you can run
$ make eth-deploy-proxy
to deploy the proxy contract and make it the admin of EthCustodian.
For more advanced usage, please examine the hardhat.config.js file which contains a lot of scripts that are performed
in this step-by-step guide via more simplified make commands. You can see the list of available tasks by running:
$ yarn hardhat
To show help and required arguments on how to use the specific task from the task list, use the following command structure:
$ yarn hardhat <TASK_NAME> --help
e.g.:
$ yarn hardhat eth-deposit-to-evm --help