This get starter to run example available in rosetta-client.
Ethereum:
Setting up nodes
-
First you need to build connectors for that you can run
./build_connectors.shif you are running on mac you might get gcc error. To solve it please do following. -
Run
rustup target add x86_64-unknown-linux-muslin mac. -
In
~/.cargo/configadd following
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
- In
build_connectors.shreplacecargo buildwithTARGET_CC=x86_64-linux-musl-gcc cargo build - Run
./build_connectors.sh. - After conenctors are build run
docker compose up.
Compiling voting contract
- We have a
voting_contract.solwe have to compile and get its binary in order to deploy it. For this you need to havesolcinstalled. You can install it usingbrew install solidityorsudo apt-get install solc. - Run
solc --combined-json abi,bin --abi --bin voting_contract.sol -o ./voting_contract_filesin contract folder. - You will get
voting_contract_filesfolder withvoting_contract.abi,voting_contract.binandcombined_voting_contract.jsonwhich contains both abi and bin since we are only concerned with bin we will usevoting_contract.bin. and for sake of easiness we have already compiled and imported it in examples folder.
Running voting_contract example
- This example demonstrate how to interact with smart contract using Aanlog's wallet. We will deploy a basic contracts storing yes or no votes and displays total votes on voting.
- Run
cargo run --example voting_contract faucet. to get some funds to deploy contract. - To deploy contract run
cargo run --example voting_contract deploy. You will get deployed contract address as output, make sure you copy it. - To vote for yes run
cargo run --example voting_contract vote --contract-address "0x678ea0447843f69805146c521afcbcc07d6e28a2" -vTo vote for no runcargo run --example voting_contract vote --contract-address "0x678ea0447843f69805146c521afcbcc07d6e28a2"you will getCallResponseas output containing n array first uint is total ofyesvotes and second fornovotes in contract.
Running ethereum example
- This examples demonstrate how to interact with ethereum using Analog's wallet.
- Make sure you have voting contract deployed. If not please follow voting_contract example steps 2 and 3.
- Run
cargo run --example ethereum -- --contract-address "0x678ea0447843f69805146c521afcbcc07d6e28a2" - It runs all available methods available for wallet and respond with valid output.