Wrapped CSPR (WCSPR) — a CEP-18 (ERC-20 style) wrapper for the native CSPR token on the Casper network, built with the Odra framework.
Wrapping native CSPR into a fungible token lets it be used by smart contracts and protocols (DEXes, lending markets, etc.) that expect a standard token interface. Depositing CSPR mints an equal amount of WCSPR, and withdrawing burns WCSPR to release the underlying CSPR.
This crate ships two contract versions. WCSPRV2 is an upgrade of WCSPRV1 that keeps the
original storage and adds gasless, signature-based authorization transfers.
A CEP-18 compliant wrapped-token contract (see src/wcspr_v1.rs).
- Token metadata: name
Wrapped CSPR, symbolWCSPR,9decimals. deposit(payable) — wraps attached CSPR, minting an equal amount of WCSPR to the caller and emitting aDepositevent.withdraw(amount)— burns the caller's WCSPR and returns the native CSPR, emitting aWithdrawalevent. If the caller is a contract, CSPR is delivered viaCsprDepositContractRef.withdraw_to(recipient, amount)— burns the caller's WCSPR and sends the native CSPR directly torecipient, avoiding an intermediate transfer.- Standard CEP-18 methods:
name,symbol,decimals,total_supply,balance_of,allowance,approve,increase_allowance,decrease_allowance,transfer,transfer_from.
An upgrade of WCSPRV1 that composes the original token with the CEP3009 module to add
authorization-based (gasless / meta) transfers (see src/wcspr_v2.rs).
init(chain_name)— initializes the underlying V1 token and the CEP-3009 module.upgrade(chain_name)— initializes the CEP-3009 module when upgrading from V1.- Re-exposes all
WCSPRV1methods (includingdeposit,withdraw,withdraw_to). - Adds CEP-3009 methods:
authorization_state(authorizer, nonce)transfer_with_authorization(...)receive_with_authorization(...)cancel_authorization(...)
src/
lib.rs # crate root, exposes wcspr_v1 and wcspr_v2 modules
wcspr_v1.rs # WCSPRV1 contract + unit tests
wcspr_v2.rs # WCSPRV2 contract (V1 + CEP-3009)
bin/
build_contract.rs # Wasm contract build entrypoint
build_schema.rs # contract schema generation entrypoint
cli.rs # Odra CLI: deploy script + upgrade scenario
Odra.toml # registers WCSPRV1 and WCSPRV2 contracts
justfile # common developer commands
- The Rust toolchain pinned in rust-toolchain.
- The
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown. just(optional, for the helper commands).
Build the Wasm contracts using the Odra build pipeline:
cargo odra buildGenerate the contract schemas:
cargo odra schemaRun the unit tests against the Odra MockVM:
cargo odra testThe tests in src/wcspr_v1.rs cover initialization, deposits, minting, withdrawals, and the relevant error cases.
A CLI binary is provided to deploy the contract and run on-chain scenarios
(see bin/cli.rs). Run it via the justfile:
just cli <ARGS>or directly with cargo:
cargo run --bin wcspr_cli -- <ARGS>WCSPRV1DeployScript deploys WCSPRV1 as an upgradable contract registered under the package
named key WrappedNativeToken. This named key must match the one used on testnet and mainnet, so
it should not be changed.
The upgrade_v1_to_v2 scenario upgrades a deployed WCSPRV1 to WCSPRV2. It accepts a single
argument:
chain_name— the name of the blockchain network, used to initialize the CEP-3009 module.