The Token contract is a modified implementation of the CW20 base, refitted to consider for bETH reward accruals.
Details on the CW20 specification can be found here.
Contract State
TokenInfo
Stores information about the bETH token.
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub struct TokenInfo {
pub name: String,
pub symbol: String,
pub decimals: u8,
pub total_supply: Uint128,
pub mint: Option<MinterData>,
}
Number of decimals of bETH
Total minted supply of bETH
Minter information of bETH
* = not stored until value registered
MinterData
Store information about the bETH minter.
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct MinterData {
pub minter: Addr,
pub cap: Option<Uint128>,
}
Maximum number of mintable tokens
* = not stored until value registered
InstantiateMsg
#[derive(Serialize, Deserialize, JsonSchema)]
pub struct TokenInstantiateMsg {
pub name: String,
pub symbol: String,
pub decimals: u8,
pub initial_balances: Vec<Cw20CoinHuman>,
pub mint: Option<MinterResponse>,
pub reward_contract: String,
}
{
"name": "Bonded ETH",
"symbol": "BETH",
"decimals": 6,
"total_supply": "100000000",
"mint": {
"minter": "terra1...",
"cap": "1000000000"
},
"reward_contract": "terra1..."
}
Number of decimals of bETH
Total minted supply of bETH
Minter information of bETH
Contract address of bETH Reward
* = optional
ExecuteMsg
Transfer
Transfers tokens to the specified address.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
Transfer {
recipient: String,
amount: Uint128,
}
}
{
"transfer": {
"recipient": "terra1...",
"amount": "100000000"
}
}
Recipient address of token transfer
Amount of tokens to transfer
Burn
Burns the specified amount of tokens.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
Burn {
amount: Uint128,
}
}
{
"burn": {
"amount": "100000000"
}
}
Send
Sends tokens to the specified contract address along with a message.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
Send {
contract: String,
amount: Uint128,
msg: Binary,
}
}
{
"send": {
"contract": "terra1...",
"amount": "100000000",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmluYXJ5IiB9"
}
}
Contract address to send tokens to
Base64-encoded JSON of receive hook message
Mint
Mints tokens to the specified address. Can only be issued by the minter.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
Mint {
recipient: String,
amount: Uint128,
}
}
{
"mint": {
"recipient": "terra1...",
"amount": "100000000"
}
}
Address to mint tokens to
IncreaseAllowance
Increases allowance for the specified spender address.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
IncreaseAllowance {
spender: String,
amount: Uint128,
expires: Option<Expiration>,
}
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Expiration {
AtHeight(u64),
AtTime(Timestamp),
Never {},
}
{
"increase_allowance": {
"spender": "terra1...",
"amount": "100000000",
"expires": {
"at_height": 123123,
// or
"at_time": 123123,
// or
"never": {}
}
}
}
Amount of tokens to increase allowance for spender
Information on when this allowance expires
* = optional
Allowance expires at specified block height
Allowance expires at specified block timestamp
DecreaseAllowance
Decreases allowance for the specified spender address.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
DecreaseAllowance {
spender: String,
amount: Uint128,
expires: Option<Expiration>,
}
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Expiration {
AtHeight(u64),
AtTime(Timestamp),
Never {},
}
{
"decrease_allowance": {
"spender": "terra1...",
"amount": "100000000",
"expires": {
"at_height": 123123,
// or
"at_time": 123123,
// or
"never": {}
}
}
}
Amount of tokens to decrease allowance for spender
Information on when this allowance expires
Allowance expires at specified block height
Allowance expires at specified block timestamp
TransferFrom
Transfers tokens from the specified owner to the specified recipient. Requires unexpired allowance to be set beforehand.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
TransferFrom {
owner: String,
recipient: String,
amount: Uint128,
}
}
{
"transfer_from": {
"owner": "terra1...",
"recipient": "terra1...",
"amount": "100000000"
}
}
Address to transfer tokens from
Address to transfer tokens to
Amount of tokens to transfer
SendFrom
Sends tokens from the specified owner to the specified contract, along with a message. Requires unexpired allowance to be set beforehand.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
SendFrom {
owner: String,
contract: String,
amount: Uint128,
msg: Binary,
}
}
{
"send_from": {
"owner": "terra1...",
"contract": "terra1...",
"amount": "100000000",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmluYXJ5IiB9",
}
}
Address to send tokens from
Address to send tokens to
Base64-encoded JSON of receive hook msg
BurnFrom
Burns tokens from the specified owner. Requires unexpired allowance to be set beforehand.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20ExecuteMsg {
BurnFrom {
owner: String,
amount: Uint128,
}
}
{
"burn_from": {
"owner": "terra1...",
"amount": "100000000"
}
}
Address to burn tokens from
QueryMsg
Balance
Gets the balance for the specified address.
Request
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
Balance {
address: String,
}
}
Address of holder to get balance
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct BalanceResponse {
pub balance: Uint128,
}
Request
{
"balance": {
"address": "terra1..."
}
}
Address of holder to get balance
Response
{
"balance": "100000000"
}
TokenInfo
Gets information for the token.
Request
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
TokenInfo {}
}
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct TokenInfoResponse {
pub name: String,
pub symbol: String,
pub decimals: u8,
pub total_supply: Uint128,
}
Number of decimals of token
Total minted supply of token
Request
Response
{
"name": "Bonded ETH",
"symbol": "BETH",
"decimals": 6,
"total_supply": "1000000000"
}
Number of decimals of token
Total minted supply of token
Minter
Gets information for the token minter.
Request
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
Minter {}
}
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct MinterResponse {
pub minter: String,
pub cap: Option<Uint128>,
}
Maximum number of mintable tokens
Request
Response
{
"minter": "terra1...",
"cap": "1000000000"
}
Maximum number of mintable tokens
Allowance
Gets allowance information for the specified owner and spender.
Request
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
Allowance {
owner: String,
spender: String,
}
}
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)]
pub struct AllowanceResponse {
pub allowance: Uint128,
pub expires: Expiration,
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Expiration {
AtHeight(u64),
AtTime(Timestamp),
Never {},
}
Amount of owner's tokens spender is allowed to spend
Information on when this allowance expires
Allowance expires at specified block height
Allowance expires at specified block timestamp
Request
{
"allowance": {
"owner": "terra1...",
"spender": "terra1..."
}
}
Response
{
"allowance": "100000000",
"expires": {
"at_height": 123123,
// or
"at_time": 123123,
// or
"never": {}
}
}
Amount of owner's tokens spender is allowed to spend
Information on when this allowance expires
Allowance expires at specified block height
Allowance expires at specified block timestamp
AllAllowances
Gets all allowance information for the specified owner.
Request
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
AllAllowances {
owner: String,
start_after: Option<String>,
limit: Option<u32>,
}
}
Address of spender to start query
Maximum number of query entries
* = optional
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)]
pub struct AllAllowancesResponse {
pub allowances: Vec<AllowanceInfo>,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct AllowanceInfo {
pub spender: String,
pub allowance: Uint128,
pub expires: Expiration,
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Expiration {
AtHeight(u64),
AtTime(Timestamp),
Never {},
}
List of allowance information
Amount of owner's tokens spender is allowed to spend
Information on when this allowance expires
Allowance expires at specified block height
Allowance expires at specified block timestamp
Request
{
"all_allowances": {
"owner": "terra1...",
"start_from": "terra1...",
"limit": 10
}
}
Address of spender to start query
Maximum number of query entries
* = optional
Response
{
"allowances": [
{
"spender": "terra1...",
"allowance": "100000000",
"expires": {
"at_height": 123123,
// or
"at_time": 123123,
// or
"never": {}
}
},
{
"spender": "terra1...",
"allowance": "100000000",
"expires": {
"at_height": 123123,
// or
"at_time": 123123,
// or
"never": {}
}
},
]
}
List of allowance information
Amount of owner's tokens spender is allowed to spend
Information on when this allowance expires
Allowance expires at specified block height
Allowance expires at specified block timestamp
AllAccounts
Gets account information for all holders.
Request
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw20QueryMsg {
AllAccounts {
start_after: Option<String>,
limit: Option<u32>,
}
}
Address of holder to start query
Maximum number of query entries
* = optional
Response
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)]
pub struct AllAccountsResponse {
pub accounts: Vec<String>,
}
Request
{
"all_accounts": {
"start_after": "terra1...",
"limit": 8
}
}
Address of holder to start query
Maximum number of query entries
* = optional
Response
{
"accounts": [
"terra1...",
"terra1...",
"terra1..."
]
}