Explore ADM's functionalities through these practical examples.
All the examples target an adm
testnet subnet anchored to the Filecoin Calibration network.
You can run them with cargo run --example [example name] - [ARG]
.
account_create.rs
creates a random local private key for use in the other examples.
cargo run --example account_create
Example output:
Private key: b630e3ffca6a5a35378520f5d803b1ad8622663420e91198ad16da546e041ed6
Address: 0x9c094a4a1376d24cb83667567dec2d6b2ba4944e
FVM address: t410ftqeuusqto3jezobwm5lh33bnnmv2jfcoijdi44q
To create transactions in the adm
testnet, you need to first deposit some Calibration tFIL in the adm
subnet.
- Go to the Calibration faucet and click "Send Funds".
- Enter an Ethereum address.
This can be any valid Ethereum address,
like the one given by running the
account_create.rs
example. - Look up the address you used on the Calibration explorer. After about a minute, you should have 100 tFIL.
- Now you're ready to make a deposit to the
adm
testnet subnet.
Run the account_deposit.rs
example using the private key for the address you used above.
cargo run --example account_deposit -- [YOUR_HEX_ENCODED_PRIVATE_KEY]
Example output:
Deposited 1 tFIL to 0x9c094a4a1376d24cb83667567dec2d6b2ba4944e
Transaction hash: 0x03d40fc3e8d629b2b52805e4fd1fb93f2d31bb06feaa3da55408091cbde6a654
account_balance.rs
shows the balance of an account in the adm
testnet subnet.
If you ran the account_deposit.rs
, this should show a non-zero balance after a few minutes.
cargo run --example account_balance -- [YOUR_HEX_ENCODED_PRIVATE_KEY]
Example output:
Balance of 0x9c094a4a1376d24cb83667567dec2d6b2ba4944e: 1.0
Read the docs (run make doc
from the repo root) for more account methods.
objectstore_add.rs
creates a new object store, adds an object, and then queries for it by key.
To run this example, you must deposit some funds into the adm
testnet subnet.
cargo run --example objectstore_add -- [YOUR_HEX_ENCODED_PRIVATE_KEY]
Example output:
Created new object store t2stfvbana4ljpvxdxit7ls23tt42owa2uy4isveq
Transaction hash: 0x005B93799842089F1AF25304D38FAD9995D5AC1C67D940A38E02383E984CADFB
Added 1MiB file to object store t2stfvbana4ljpvxdxit7ls23tt42owa2uy4isveq with key foo/my_file
Transaction hash: 0xC49C5E0FBC62774C0A3C4AD24D4151D996F8BC9168C369A1A67D9049DA0A0278
Query result cid: bafybeidm37d6cxxoyu5fpadpuycta2wenno6ogmzi7uh3gsfd4e4c6tyda (key=foo/my_file; detached; resolved=true)
Read the docs (run make doc
from the repo root) for more object store methods.
accumulator_push.rs
creates a new accumulator for state updates, pushes a new value,
gets it back, and then qeuries for the accumulator's count and state root.
To run this example, you must deposit some funds into the adm
testnet subnet.
cargo run --example accumulator_push -- [YOUR_HEX_ENCODED_PRIVATE_KEY]
Example output:
Created new accumulator t2hmsh5t5rhrlhsl3igo35rh35lt4woboxzghpujq
Transaction hash: 0x54ECC3EA468D7FA3FAD165B8EAE6DEB0FECD88C53738E5E1C32BE3925E7AB886
Pushed to accumulator t2hmsh5t5rhrlhsl3igo35rh35lt4woboxzghpujq with index 0
Transaction hash: 0x1D5DF1C9BB5CA5C5F14F8AC1D17188BB0EFE3D735A8A03A16EBB331D1FDEF0BF
Value at index 0: 'my_value'
Count: 1
State root: bafy2bzacecqsdwyjka2novzw77zex3mumho7r7q6ddcx7vgzy75fe5zqsbkxo
Read the docs (run make doc
from the repo root) for more accumulator methods.