1 stable release
1.0.0 | May 6, 2024 |
---|
#22 in #wrapped
27KB
348 lines
Wrapped AZERO
This repository contains an ink! smart contract for Aleph Zero blockchain which enables wrapping the native chain coin (AZERO) into a fungible token following PSP22 standard.
The contract is deployed to both test and main networks under the following addresses:
- Aleph Zero Mainnet:
5CtuFVgEUz13SFPVY6s2cZrnLDEkxQXc19aXrNARwEBeCXgg
- Aleph Zero Testnet:
5EFDb7mKbougLtr5dnwd5KDfZ3wK55JPGPLiryKq4uRMPR46
The artifacts
folder contains the exact compiled binary that has been deployed, as well as all other compilation artifacts for verification purposes.
The contents of this repository has been published to crates.io to allow for easy integration from other projects.
How to interact with Wrapped AZERO from other contracts
- Add the wrapped-azero dependency in your project's
Cargo.toml
:
wrapped-azero = { version = "1.0", default-features = false, features = ["ink-as-dependency"] }
# ...
[features]
# ...
std = [
# ...
"wrapped-azero/std",
]
- To call
deposit
andwithdraw
methods from your contract, usecontract_ref
macro withWrappedAZERO
trait:
use ink::{codegen::TraitCallBuilder, contract_ref};
use wrapped_azero::{WrappedAZERO, MAINNET};
let mut wazero: contract_ref!(WrappedAZERO) = MAINNET.into();
wazero.withdraw(amount); // returns Result<(), PSP22Error>
// Deposit call must be composed manually to be able to attach AZERO transfer
wazero.call_mut().deposit().transferred_value(amount).invoke(); // returns Result<(), PSP22Error>
- To call regular PSP22 methods (transfers, balances, approvals) from your contract, use
contract_ref
macro withPSP22
trait:
use ink::contract_ref;
use ink::prelude::vec;
use wrapped_azero::{PSP22, MAINNET};
let mut wazero: contract_ref!(PSP22) = MAINNET.into();
let balance = wazero.balance_of(some_account);
wazero.transfer(recipient, value, vec![]); // returns Result<(), PSP22Error>
How to interact with Wrapped AZERO manually via web interface
- Go to Contracts UI.
- Select "Aleph Zero" (or "Aleph Zero Testnet") from the networks menu in top left corner.
- Choose "Add New Contract" and then "Use On-Chain Contract Address".
- Paste the Mainnet (Testnet) address listed above.
- Choose any name you like and use the metadata file from
artifacts
folder. - Choose the caller and the method to call. For read-only methods (like
psp22::balanceOf
) you will see the response immediately. For other methods fill in the parameters (leave all the limits with their default values) and sign the transaction (you need to have Aleph Zero Signer or similar browser extension connected with Contracts UI).
Dependencies
~8–12MB
~214K SLoC