How to use Ancon Protocol Hybrid Smart Contracts

IFESA
1 min readDec 25, 2021
  1. Clone Ancon Protocol contracts repo. https://github.com/anconprotocol/contracts

You will see there are 4 files in contracts/metadata/src example :

  • sdk.rs — contains host wrappers
  • lib.rs — main entry
  • host.rs — host entry
  • contract.rs — here is where graphql dag contracts are implemented

Eg metadata retrieval and mutation looks like this:

DID accounts

Before being able to work with smart contracts, create a DID accounts. This account will be anchored in a blockchain and stored as DAG in ipfs. Ancon Protocol relies on DID to manage L2 and cross chain ownership of data, ie non fungible tokens.

Creating and enrolling a DID will have a cost once the platform is enabled.

Uploading contracts

To upload a rust wasm smart contract, sign a payload message with your did account private key and attached message with signature. You can follow the deployer-contract.ts example in playground folder 📂.

You will get a cid which is where the smart contract is stored.

Executing contracts

Similar to deployer-contract.ts, there is a execute-contract.ts, this will send a JSON-RPC request with the following properties:

  • to — the smart contract cid
  • from — the sender DID cid address (later releases will support both cid and did)
  • data — graph ql query
  • signature — payload signature

If everything goes well, convert the results to plain text from hex and parse with JSON.parse.

In the next post we’ll go through the proof implementation using vector commitments with ICS23 and using L1 consensus to validate proofs.

--

--

IFESA

Industrias de Firmas Electrónicas, S.A. (IFESA) es la primera empresa panameña dedicada a tecnologías basadas en algoritmos criptográficos, firmas electrónicas,