☝️Token Contract Interaction
For the token contract interaction, you first need to clone the following repository: https://github.com/stellar/soroban-examples/ and build the token project. This will generate a soroban_token_contract.wasm file which we can deploy to interact with the token contract.
Deploy:
This deploys the token contract to the futurenet. You will receive a contract ID (TOKEN_CONTRACT_ID).
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022'Check Balance:
You can check the balance of any USER_ADDRESS with the following command:
soroban contract invoke \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--id ${TOKEN_CONTRACT_ID} \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022' \
-- balance --id ${USER_ADDRESS}Make Admin:
An existing admin can promote any USER_ADDRESS to admin status using the following command:
soroban contract invoke \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--id ${TOKEN_CONTRACT_ID} \
--source ${ADMIN_SECRET_KEY} \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022' \
-- set_admin --new_admin ${USER_ADDRESS}Check Authorization:
You can check if USER_ADDRESS is authorized to spend their balance with the following command:
soroban contract invoke \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--id ${TOKEN_CONTRACT_ID} \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022' \
-- authorized --id ${USER_ADDRESS}Change Authorization:
An admin can authorize any USER_ADDRESS to spend their balance with the following command:
soroban contract invoke \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--id ${TOKEN_CONTRACT_ID} \
--source ${ADMIN_SECRET_KEY} \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022' \
-- set_authorized --id ${USER_ADDRESS} -authorizeRemember to replace ${TOKEN_CONTRACT_ID}, ${USER_ADDRESS}, and ${ADMIN_SECRET_KEY} with actual values in your environment.
Last updated