wrapped-azero

Crates.iowrapped-azero
lib.rswrapped-azero
version1.0.0
sourcesrc
created_at2024-05-06 14:47:31.531672
updated_at2024-05-06 14:47:31.531672
descriptionSmart contract for AZERO coin wrapped as a PSP22 token
homepagehttps://github.com/Cardinal-Cryptography/wAZERO
repositoryhttps://github.com/Cardinal-Cryptography/wAZERO
max_upload_size
id1231209
size106,988
cardinal-crate-owner (cardinal-crate-owner)

documentation

README

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

  1. 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",
]

  1. To call deposit and withdraw methods from your contract, use contract_ref macro with WrappedAZERO 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>

  1. To call regular PSP22 methods (transfers, balances, approvals) from your contract, use contract_ref macro with PSP22 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

  1. Go to 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 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).
Commit count: 44

cargo fmt