This step is performed by the User that wants to interact with the contract.
This guide explains how to interact with a deployed contract using the CLI and the Verifiable Authorisation To Invoke credential.
Prerequisites
- The user has received a
VerifiableAuthorisationToInvokecredential from the entity that manages the use case - The user has access to the contract's ABI (Application Binary Interface)
Steps
1. Open the CLI tool
Start the CLI and load your keys:
env test # or pilot/production
using user ES256K did1 <private-key> <did>
2. Request an access token
Request an access token from the authorization API using your VC:
res: authorisation auth ledger_invoke_presentation ES256 <VC>
where VC is the Verifiable Authorisation To Invoke credential you received.
3. Load the access token
Use the access token from the response:
using token res.access_token
4. Load the contract ABI
Load the ABI of the contract:
abi: load path-to-abi.json
5. Interact with the contract
Use the Ledger API to interact with the contract:
Read data from the contract
To read data, use the get command:
ledger get <address> abi <readMethod> <param0> <param1> ...
where:
address: The contract addressreadMethod: Name of the read functionparam0,param1, etc.: Parameters for the function
Submit transactions to the contract
To submit transactions, use the send command:
ledger send <address> abi <writeMethod> <param0> <param1> ...
where:
address: The contract addresswriteMethod: Name of the write functionparam0,param1, etc.: Parameters for the function
You can now interact with the contract using the read and send commands as needed.
Make sure to use the correct function names and parameters as defined in the contract's ABI.