This repository contains crates of chain extension that you can use in your contracts.
To know which chain extension is available in which networks and have more info about it please visit the official Chain Extension docs
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
This crate exposes AssetsExtension
struct that implement all functions of pallet-assets chain extension.
Usage
- add
assets_extension
in yourCargo.toml
and to thestd
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",
]
- Add use statement in your contract module
use assets_extension::*;
- 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
This crate exposes DappsStaking
struct that implement all functions of dapps-staking chain extension.
Usage
- add
dapps_staking_extension
in yourCargo.toml
and to thestd
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"
]
- Add use statement in your contract module
pub mod staking_example {
use dapps_staking_extension::*;
...
- Use struct functions directly in your contract
DappsStaking::read_unbonding_period()
This crate exposes SchedulerExtension
struct that implement functions of pallet-scheduler chain extension.
Usage
- add
scheduler_extension
in yourCargo.toml
and to thestd
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",
]
- Add use statement in your contract module
use scheduler_extension::*;
- 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
Apache 2.0
Use these instructions to set up your ink!/Rust environment
Run this command in the contract folder:
cargo contract build
First start your local node.
Deploy using contracts UI. Instructions on Astar docs
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
- Add the path of the node (astar-local or swanky). example:
export CONTRACTS_NODE="/home/astar/Documents/astar/Astar/target/release/astar-collator"
- Run the tests
cargo test --features e2e-tests