Wrapped R5 (Native)
This page describes the Wrapped R5 (WR5) token contract, its rationale, interface, and integration guidelines for developers building on the R5 network.
Canonical WR5 address on R5 Mainnet, Testnet, and Devnet:
Overview
Wrapped R5 (WR5) is an ERC-20–compatible token that represents native R5 coins in a smart-contract form. It enables R5 to participate in DeFi protocols, DEXs, and other smart-contract–based systems.
Token Name: Wrapped R5
Symbol: WR5
Decimals: 18
Contract Standards: Minimal ERC-20 + wrap/unwrap functions
Solidity Version: 0.8.29
Motivation
Native R5 transfers are handled by the consensus layer and cannot directly interact with EVM-based contracts. WR5 bridges this gap by:
Wrapping: Locking native R5 in the WR5 contract in exchange for an equal amount of WR5.
Unwrapping: Burning WR5 to redeem locked R5.
This allows seamless integration with ERC-20 tooling (DEXs, lending platforms, wallets).
Contract Architecture
The contract maintains two primary mappings:
balanceOf[account]: WR5 token balance of
account
.allowance[owner][spender]: Remaining WR5
spender
may transfer on behalf ofowner
.
Native R5 held by the contract (address(this).balance
) equals total WR5 supply.
Key Functions
Function
Signature
Description
deposit
function deposit() external payable
Wrap native R5: mints WR5 = msg.value
, credited to msg.sender
.
withdraw
function withdraw(uint256 amount) external
Unwrap WR5: burns amount
WR5, sends amount
native R5 to caller.
totalSupply
function totalSupply() external view returns(uint256)
Returns total WR5 (contract’s R5 balance).
approve
function approve(address spender, uint256 amount) external returns(bool)
Set allowance for spender
.
transfer
function transfer(address to, uint256 amount) external returns(bool)
Transfer WR5 from caller to to
.
transferFrom
function transferFrom(address from, address to, uint256 amount) external returns(bool)
Transfer WR5 on behalf (uses allowance).
Wrapping & Unwrapping
receive()
andfallback()
invokedeposit()
, allowing simplesendTransaction({ to: WR5, value })
.
Events
Event
Signature
Emitted When
Deposit
event Deposit(address indexed to, uint256 amount)
User wraps native R5
Withdrawal
event Withdrawal(address indexed from, uint256 amount)
User unwraps WR5
Transfer
event Transfer(address indexed from, address indexed to, uint256 value)
Standard ERC-20 transfer
Approval
event Approval(address indexed owner, address indexed spender, uint256 value)
Standard ERC-20 approval
Security Considerations
Reentrancy: Withdrawal uses
transfer
, which caps gas and reverts on failure—mitigating reentrancy.Overflow/Underflow: Solidity 0.8’s built‑in checks prevent arithmetic errors.
Infinite Allowance:
type(uint256).max
sentinel avoids unnecessary storage writes when users want unlimited allowance.Ownership: No admin or upgradeable logic; the contract is immutable once deployed.
Gas Efficiency
Minimal storage writes (no mint/burn hooks beyond mapping updates).
Single‐contract, minimal-function interface reduces deployment footprint.
Avoids external library calls (SafeMath, OZ code) thanks to built‑in checks.
Integration Examples
Web3.js
Ethers.js
ABI Reference
A minimal ABI for WR5 interactions:
Last updated