Updated on April 1, 2022
Interact with the rollup smart contract
ConsenSys Rollups provides a smart contract for users to interact with partially anonymous rollups.
Users can interact with the smart contract by sending inbound transfers to the smart contract to have the smart contract to manage their tokens, and by sending tokens between accounts.
ConsenSys Rollups provides accounts with test ether with which you can test the smart contract.
Security warning
Do not use the test accounts on Ethereum mainnet or any production network.
The test accounts provided in the ConsenSys Rollups repository are not secure; their private keys are publicly visible in the source code.
Using test accounts on Ethereum mainnet and production networks can lead to loss of funds and identity fraud.
Always secure your Ethereum mainnet and production accounts properly. For example, see MyCrypto “Protecting Yourself and Your Funds” guide.
Prerequisites
- ConsenSys Rollups installed and running.
Navigate to the
smart_contracts
directory to run the example commands. - Node.js installed.
- Truffle installed.
-
Address of the Ethereum RPC set as the following environment variable:
export BLOCKCHAIN_NODE=<RPC-address>
export BLOCKCHAIN_NODE=http://localhost:8545
Send inbound transfers to smart contract
You can send inbound transfers in ETH or ERC-20 token to the smart contract using the following commands.
In ETH
node scripts/registerInboundEth.js data/rollup.json <path-to-Ethereum-account> <account-id-in-rollup> <amount-in-ETH>
node scripts/registerInboundEth.js data/rollup.json ../node-data/test/keys/eth_account_3.acc 0 100.3333
The transfer amount is in ETH, not Wei.
In ERC-20
node scripts/registerInboundErc20.js data/rollup.json <path-to-Ethereum-account> <account-id-in-rollup> <token-id> <transfer-value>
node scripts/registerInboundErc20.js data/rollup.json ../node-data/test/keys/eth_account_3.acc 0 0 10000000
The transfer amount is in the smallest unit of the ERC-20 token.
Send ERC-20 tokens between accounts
You can send ERC-20 tokens between accounts using the following command.
truffle exec scripts/truffle/transferErc20To.js <erc20-address> <priv-key> <to> <amount>
truffle exec scripts/truffle/transferErc20To.js $(cat data/erc20_addr.addr) $(jq -r .priv_key ../node-data/test/keys/eth_account_10.acc) $(jq -r .address data/rollup.json) 3000
The transfer amount is in the smallest unit of the ERC-20 token.