For this example we will be using the contract example_contract.cairo
- Having cairo-lang installed
- Having built starknet-rs using
cargo build --release
target/release/starknet-rs starknet_in_rust
starknet-compile contract_execution_examples/example_contract.cairo --output example_contract.json --abi example_contract_abi.json
target/release/starknet-rs declare --contract example_contract.json
This will return the following data:
Contract class hash: 0x585725368e79f1757ffeb4baa04548c314d652993c6c9e726bdd754e78d8c7a
Transaction hash: 0x3826a3cf201d397a7929e6cc651e065097adb87e3759079e851bdaa38e74421
Pass the class_hash obtained when declaring the contract to deploy
target/release/starknet-rs deploy --class_hash 0x585725368e79f1757ffeb4baa04548c314d652993c6c9e726bdd754e78d8c7a
This will return the following data:
Invoke transaction for contract deployment was sent.
Contract address: 0x76c1d19703043d7ef9ff3450db76e0b31787b57b06d89ad97cbfddeee3decd1
Transaction hash: 0x13699fd1061f0668fc44bc96c348626abfff406010eef89624b3ddae6e02776
Invoke the method increase_balance
with the input 1234 in order to update the balance
storage variable
target/release/starknet-rs invoke \
--address 0x76c1d19703043d7ef9ff3450db76e0b31787b57b06d89ad97cbfddeee3decd1 \
--abi example_contract_abi.json \
--function increase_balance \
--inputs 1234
The result should look like this:
Invoke transaction was sent.
Contract address: 0x76c1d19703043d7ef9ff3450db76e0b31787b57b06d89ad97cbfddeee3decd1
Transaction hash: 0x3719bf767be2a666f3c23e3cf97accafab4cfc528c20cd3a42655c35818be55
Call the method get_balance
in order to query the updated balance
target/release/starknet-rs call \
--address 0x76c1d19703043d7ef9ff3450db76e0b31787b57b06d89ad97cbfddeee3decd1 \
--abi example_contract_abi.json \
--function get_balance
This will return the updated balance:
1234