autonomi - Autonomi client API
Connect to and build on the Autonomi network.
Usage
Add the autonomi crate to your project with cargo add:
Example
use ;
async
In the above example the wallet is setup to use the default EVM network (Arbitrum One). Instead we can use a different network:
use ;
// Arbitrum Sepolia
let wallet = new_from_private_key ?;
// Custom (e.g. local testnet)
let wallet = new_from_private_key ?;
Running tests
To run the tests, we can run a local network:
-
Run a local EVM node:
Note: To run the EVM node, Foundry is required to be installed: https://book.getfoundry.sh/getting-started/installation
-
Run a local network and use the local EVM node.
-
Then run the tests and pass the EVM params again:
EVM_NETWORK=local
Using a live testnet or mainnet
Using the hardcoded Arbitrum One option as an example, but you can also use the command flags of the steps above and
point it to a live network.
- Run a local network:
- Then pass the private key of the wallet, and ensure it has enough gas and payment tokens on the network (in this case Arbitrum One):
EVM_NETWORK=arbitrum-one EVM_PRIVATE_KEY=<PRIVATE_KEY> cargo
Using funds from the Deployer Wallet
You can use the Deployer wallet private key printed in the EVM node output to initialise a wallet from with almost
infinite gas and payment tokens. Example:
let rpc_url = "http://localhost:54370/";
let payment_token_address = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
let data_payments_address = "0x8464135c8F25Da09e49BC8782676a84730C318bC";
let private_key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
let network = Custom;
let deployer_wallet = new_from_private_key.unwrap;
let receiving_wallet = new_with_random_wallet;
// Send 10 payment tokens (atto)
let _ = deployer_wallet
.transfer_tokens
.await;
Alternatively, you can provide the wallet address that should own all the gas and payment tokens to the EVM testnet
startup command using the --genesis-wallet flag:
*************************
* Ethereum node started *
*************************
RPC URL: http://localhost:60093/
Payment token address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Chunk payments address: 0x8464135c8F25Da09e49BC8782676a84730C318bC
Deployer wallet private key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Genesis wallet balance: (tokens: 20000000000000000000000000, gas: 9998998011366954730202)
Python
For documentation on the Python bindings, see [./README_PYTHON.md].