Running smart contract locally

Prerequisites

Ensure mini-ola is installed correctly:

mini-ola --version

If this command fails, see Setting up your environment.

Interacting with a smart contract locally

You can write Ola smart contracts using Ola-lang and compile them with olatte, Taking the vote_simple.ola contract as an example:

olatte compile path/to/vote_simple.ola path/of/output/dir

This command will generate a bin file and an abi file; the bin file is used for the deployment of the contract:

olatte deploy --address 0xabcd --db path/to/local/storage path/to/vote_simple_bin.json.json
  • address: The address where you want the smart contract to be deployed. When not specified, an address will be generated randomly.

  • db: Path of your local storage. When not specified, a "db" folder will be created in current working directory.

The contract has been deployed. You can send transactions using invoke:

mini-ola invoke vote_simple_abi.json 0xabcd contract_init "[1,2,3,4,5,6,7]"
mini-ola invoke vote_simple_abi.json 0xabcd vote_proposal 4

These two transactions initialized the proposal number and cast a vote for the fourth proposal.

When using invoke, you can specify parameters: db, caller, nonce, block, timestamp. For detailed explanations of these parameters, you can check the following command:

mini-ola invoke -h

Finally, you can use the call command to check the contract state:

mini-ola call vote_simple_abi.json 0xabcd winningProposal

Similarly, you can view specific parameters through the command:

mini-ola call -h

Last updated