https://github.com/cardinal-cryptography/wazero
ink! smart contract for AZERO wrapped as a PSP22 token
https://github.com/cardinal-cryptography/wazero
Last synced: 2 months ago
JSON representation
ink! smart contract for AZERO wrapped as a PSP22 token
- Host: GitHub
- URL: https://github.com/cardinal-cryptography/wazero
- Owner: Cardinal-Cryptography
- License: apache-2.0
- Created: 2023-10-30T17:36:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T10:32:49.000Z (about 1 year ago)
- Last Synced: 2025-03-29T18:41:36.370Z (3 months ago)
- Language: Rust
- Size: 85.9 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Wrapped AZERO
This repository contains an [ink!][ink] smart contract for [Aleph Zero][aleph] blockchain which enables wrapping the native chain coin (AZERO) into a fungible token following [PSP22][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`][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][wazero-crates] to allow for easy integration from other projects.
## How to interact with Wrapped AZERO from other contracts
1. Add the [wrapped-azero][wazero-crates] dependency in your project's `Cargo.toml`:
```TOML
wrapped-azero = { version = "1.0", default-features = false, features = ["ink-as-dependency"] }
# ...
[features]
# ...
std = [
# ...
"wrapped-azero/std",
]```
2. To call `deposit` and `withdraw` methods from your contract, use [`contract_ref`][contract_ref] macro with `WrappedAZERO` trait:
```rust
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>```
3. To call regular PSP22 methods (transfers, balances, approvals) from your contract, use [`contract_ref`][contract_ref] macro with `PSP22` trait:
```rust
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
1. Go to [Contracts UI][contracts-ui].
2. Select "Aleph Zero" (or "Aleph Zero Testnet") from the networks menu in top left corner.
3. Choose "Add New Contract" and then "Use On-Chain Contract Address".
4. Paste the Mainnet (Testnet) address listed above.
5. Choose any name you like and use the [metadata file][metadata] from `artifacts` folder.
6. 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).[traits]: ./traits.rs
[artifacts]: ./artifacts
[metadata]: ./artifacts/wrapped_azero.json
[wazero-crates]: https://crates.io/crates/wrapped-azero
[aleph]: https://alephzero.org/
[ink]: https://use.ink
[psp22]: https://github.com/inkdevhub/standards/blob/master/PSPs/psp-22.md
[contract_ref]: https://paritytech.github.io/ink/ink/macro.contract_ref.html
[contracts-ui]: https://contracts-ui.substrate.io