Skip to content

diadata-org/dia-kadena-oracles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DIA Kadena oracles

This repository contains DIA oracle smart contracts for Kadena. At the moment, the following oracles are implemented:

  • Key/value oracle with support for multiple updates in one transaction

Requirements

Installing dependencies

This project uses Yarn to manage its packages. After installing all required global dependencies, you will need to run:

yarn install
yarn build
yarn global add "file:$PWD"

Running tests

To execute all unit tests in Pact REPL:

yarn test

yarn coverage # to generate lcov report file

There is a GitHub workflow set up in this repository which runs unit tests on every push to the main branch and adds the coverage report as a comment to the corresponding commit.

Deploying smart contracts

Unlike in other protocols, Kadena smart contracts are identified by their name instead of an address. This means you can't deploy multiple contracts with the same name on one chain. Possible solutions are:

  • Deploying on a different chain (Kadena has 20 chains reserved for each network)
  • Change the module name in code manually

Note: at the moment of this writing, the dia-oracle smart contract is deployed on chains 0 and 2 of testnet04 network. The free namespace was used for all deployments.

There's is a helper CLI we developed that allows you to interact with Kadena and deploy the oracle contracts. To use it (assuming all depencies are installed), run:

dia-kadena-cli --help

This will output a help message listing all available commands.

Example of deploying a dia-oracle.pact module to testnet:

# Generate a new keypair
# (follow the instructions provided by this command to prepare your account)
dia-kadena-cli gen-keypair

# Submit the deployment transaction (testnet04 is selected by default)
dia-kadena-cli deploy pact/dia-oracle.pact --chain 4

# Verify that the contract is ready for usage
dia-kadena-cli read '(describe-module "free.dia-oracle")' --chain 4

Changing the oracle admin

Because define-keyset can only be called in top level (see Pact documentation), the ownership change functionality could not be implemented inside the contract module. Instead, you will need to execute define-keyset manually to change the oracle admin. It can be done using the same CLI:

dia-kadena-cli write '(define-keyset "free.dia-admin-keyset" (read-keyset "ks"))' \
    --keyset ks=keys-all,<YOUR PUBLIC KEY> \
    --chain 4

Important notes

  • Unlike EVM or WASM, Kadena contract are not compiled to bytecode before deploying. The full human-readable source code is uploaded to the network, which means there's no need to verify contracts on explorer.
  • We highly recommend to create different admin accounts for every oracle smart contract you deploy. Kadena accounts have a nonce, therefore it's not possible to submit multiple commands in parallell. Doing so might cause issues at runtime.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published