Skip to content

inkdevhub/chain-extension-contracts

Repository files navigation

Chain Extension contracts

This repository contains crates of chain extension that you can use in your contracts.

Extended documentation

To know which chain extension is available in which networks and have more info about it please visit the official Chain Extension docs

Purpose

In crates folder you will find the chain extension struct that implements callable functions. In examples folder you will find full implementation of the chain extension struct and its integration tests in tests folder

Versions

ink! v4.2.0
openbrush 3.1.0

Chain Extensions

Pallet Assets

This crate exposes AssetsExtension struct that implement all functions of pallet-assets chain extension.

Usage

  1. add assets_extension in your Cargo.toml and to the std features
assets_extension = {  git = "https://github.com/swanky-dapps/chain-extension-contracts", default-features = false }

[features]
default = ["std"]
std = [
    "ink_metadata/std",
    "ink/std",
    "scale/std",
    "scale-info/std",
    "assets_extension/std",
]
  1. Add use statement in your contract module
use assets_extension::*;
  1. Use struct functions directly in your contract
AssetsExtension::create(Origin::Address, asset_id, contract, min_balance)

Note: For now only call as contract Origin::Address is supported

Dapps Staking

This crate exposes DappsStaking struct that implement all functions of dapps-staking chain extension.

Usage

  1. add dapps_staking_extension in your Cargo.toml and to the std features
dapps_staking_extension = { git = "https://github.com/swanky-dapps/chain-extension-contracts", default-features = false }

[features]
default = ["std"]
std = [
    "ink_metadata/std",
    "ink/std",
    "scale/std",
    "scale-info/std",
    "dapps_staking_extension/std"
]
  1. Add use statement in your contract module
pub mod staking_example {
    use dapps_staking_extension::*;
...
  1. Use struct functions directly in your contract
DappsStaking::read_unbonding_period()

Pallet Scheduler

This crate exposes SchedulerExtension struct that implement functions of pallet-scheduler chain extension.

Usage

  1. add scheduler_extension in your Cargo.toml and to the std features
scheduler_extension = {  git = "https://github.com/swanky-dapps/chain-extension-contracts", default-features = false }

[features]
default = ["std"]
std = [
    "ink_metadata/std",
    "ink/std",
    "scale/std",
    "scale-info/std",
    "scheduler_extension/std",
]
  1. Add use statement in your contract module
    use scheduler_extension::*;
  1. Use struct functions directly in your contract
SchedulerExtension::schedule(Origin::Address, when, maybe_periodic, 0, call_input);

Note: For now only call as contract Origin::Address is supported

License

Apache 2.0

🏗️ How to use - Contracts

💫 Build

Use these instructions to set up your ink!/Rust environment
Run this command in the contract folder:

cargo contract build
💫 Deploy

First start your local node.
Deploy using contracts UI. Instructions on Astar docs

💫 Run Typechain integration test

First start your local node. This repo needs a node version of at least polkadot v0.9.37 Recommended swanky-node 1.4.0

yarn
yarn compile
yarn test
💫 Run ink! e2e test
  1. Add the path of the node (astar-local or swanky). example:
export CONTRACTS_NODE="/home/astar/Documents/astar/Astar/target/release/astar-collator"
  1. Run the tests
   cargo test --features e2e-tests

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published