https://github.com/astarnetwork/chain-extension-contracts
https://github.com/astarnetwork/chain-extension-contracts
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/astarnetwork/chain-extension-contracts
- Owner: AstarNetwork
- License: apache-2.0
- Created: 2022-07-01T16:15:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T15:47:49.000Z (over 2 years ago)
- Last Synced: 2024-04-14T01:58:36.569Z (about 2 years ago)
- Language: Rust
- Size: 622 KB
- Stars: 10
- Watchers: 13
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](https://docs.astar.network/docs/build/wasm/contract_environment/chain-extension/chain_extensions/)
### Purpose
In `crates` folder you will find the chain extension struct that implements callable functions.
In `contracts` folder you will find full implementation of the chain extension struct and its integration tests in `tests` folder
### Versions
[ink! v5.0.0-rc](https://github.com/paritytech/ink/releases/tag/v5.0.0-rc)
### 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`
```toml
assets_extension = { git = "https://github.com/AstarNetwork/chain-extension-contracts", default-features = false }
[features]
default = ["std"]
std = [
"ink/std",
"scale/std",
"scale-info/std",
"assets_extension/std",
]
```
2. Add use statement in your contract module and declare AssetsExtension type
```rust
use assets_extension::{AssetsError, AssetsExtension as _AssetsExtension};
type AssetsExtension = _AssetsExtension;
```
3. Use struct functions directly in your contract
```rust
AssetsExtension::mint(asset_id, beneficiary, amount)?;
```
Note: As precompiles in Solidity, the contract is the `caller` (the Origin of the call in the runtime)
### License
Apache 2.0
## 🏗️ How to use - Contracts
##### 💫 Build
Use these [instructions](https://use.ink/getting-started/setup) to set up your ink!/Rust environment
Run this command to compile contract:
```sh
yarn
yarn compile
```
2. Run the tests
Ensure a local node is running
```sh
yarn test
```