Skip to main content
Once a contract is deployed you interact with it in two ways view calls that read state without a transaction, and script executions that change state and cost gas.

View calls reading data

View calls are free and instant. Use them to read contract fields or call pure/view functions:
methodIndex is the zero-based position of the function in the contract source. The first public function is 0, the second is 1, and so on.

Passing arguments

Match the type names to the Ralph types declared in the function signature:

State-changing calls TxScript

To execute a function that modifies state you build and submit a transaction using a TxScript. First build the unsigned transaction:
Then sign the txId with your private key and submit:

Compile a TxScript on the fly

If you have Ralph source for a script you can compile it before building the transaction:
Use the returned bytecodeTemplate in the execute-script call above.

Reading state after a transaction

After a state-changing transaction confirms, read the updated mutFields:

Next steps

Contract events

Query events emitted by your contract

Reading contracts via API

Full guide to view calls and state reads