Skip to main content

Interacting with Contracts

To communicate with contracts on a chain, we can send eth_calls and transactions. They are validated before being sent and must follow very strict structure and types.

Basic nodes

Declaring a contract

The first step is to declare an interface toward the target contract. This interface is composed of the Abi description of the proposed methods and the coordinates with which to access the Contract. We provide the node MakeContract for this purpose, it returns a handle on which to execute future queries.

Create Contractblueprint node usage

Querying the contract

It is then possible to send EthCall requests to declared contracts in order to read data on the chain. The node EthCallContract offers a generic way to send such query.

Eth Call Contract blueprint node usage

Sending a transaction to a contract

In order to write data on the chain, we must send transactions. We currently only support transactions sent by a connected wallet. For such a case, we provide the node RequestContractTransaction.

This request is asynchronous and the response is the hash of the performed transaction as hex, empty if it did not succeed.

Request Contract Transaction blueprint node usage This node makes some assumptions about the transaction with the contract, namely : the origin address is the client's wallet id, the transaction's value is zero and all other common transaction parameters are set by the wallet. This simplifies the node but we loose some flexibility, a more complete solution might be required in the future.

Identity

We provide some helper functions to interact more seamlessly with Identity contracts :

  • GetClaimOnIdentity : Get the first Claim on a specified Topic from an Identity contract, if any.

GetClaim on Identity blueprint node usage

  • IsIdentityManager : Verify that the provided key is a managing key for the Identity contract.

Is Identity Manager blueprint node usage