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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

IFESA
IFESA

Written by 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,

No responses yet

Write a response