Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

grc20wrapdemo/v0 package

Overview

Package grc20wrapdemo is a permissionless wrapper factory for GRC20 tokens.

Point it at any token registered in gno.land/r/nt/grc20reg/v0 and it issues a new one backed by it, with a personality you pick from a list. Point it at two and it issues a meta-token backed by both. Nothing is whitelisted, nothing is owned, and the realm never gains authority over anybody's balance: every deposit is pulled with an allowance the holder granted to this realm's address.

The five wrapper modes, all from gno.land/p/moul/x/grc20wrap/v0:

Example
1plain      1:1 custody. A receipt. The boring one that proves the rest works.
2kilo       1 underlying unit becomes 1000 wrapped ones, +3 decimals.
3soulbound  wrap and unwrap freely, but the wrapped token never changes hands.
4pool       shares in the escrow: Donate raises what every share redeems for.
5sticky     pool, plus a 1% exit fee that stays behind for whoever holds on.

And one fusion mode: NewFusion bundles two registered tokens at a fixed proportion into a single meta-token, redeemable back into both.

Wrapping a wrapper

Every token this realm issues is itself registered in grc20reg, so its key can be fed straight back into NewWrapper or NewFusion. A pool over a kilo over a plain wrap of RED is legal, works, and is a good way to see how thin the abstraction really is.

The one thing a caller must do first

Approve this realm's address on the underlying token, through THAT token's own realm. Home() prints the address. Without it every Deposit fails with "insufficient allowance", which is the system working.

Play money to try it on: gno.land/r/moul/x/grc20faucet/v0.

Functions

Allowance

func Allowance(symbol string, owner, spender address) int64

Allowance returns what `owner` let `spender` draw of `symbol`.

Params

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Allowance(,,)"

Result

Approve

func Approve(cur realm, symbol string, spender address, amount int64)

Approve lets `spender` draw `amount` of `symbol` from the caller's balance.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Approve" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Approve" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

BalanceOf

func BalanceOf(symbol string, owner address) int64

BalanceOf returns `owner`'s balance of `symbol`.

Params

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.BalanceOf(,)"

Result

Count

func Count() int

Count is how many tokens this realm has issued.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Count()"

Result

Defuse

func Defuse(cur realm, symbol string, units int64)

Defuse burns `units` of `symbol` and returns every leg to the caller.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Defuse" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Defuse" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Deposit

func Deposit(cur realm, symbol string, amount int64) int64

Deposit escrows `amount` of the underlying and mints `symbol` to the caller. It returns how much was minted, which is not `amount` unless the mode is plain. Approve Home() on the underlying first.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Deposit" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Deposit" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Donate

func Donate(cur realm, symbol string, amount int64)

Donate escrows `amount` of the underlying for `symbol` and mints nothing.

Under a pool or sticky mode this is a gift to every current holder at once, and it is irreversible: there is no share to redeem it with. Under any other mode it is a gift to nobody, since the rate ignores the escrow.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Donate" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Donate" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Escrow

func Escrow(symbol string) int64

Escrow returns the underlying escrowed behind a wrapper.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Escrow()"

Result

Fuse

func Fuse(cur realm, symbol string, units int64)

Fuse escrows every leg of `symbol` and mints `units` of it to the caller. Approve Home() on BOTH legs first.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Fuse" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Fuse" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Key

func Key(symbol string) string

Key returns the grc20reg key of the token this realm issued as `symbol`.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Key()"

Result

Leg

func Leg(symbol string, i int) (string, int64, int64)

Leg describes the i-th component of a fusion: its symbol, the units escrowed per meta unit, and the units escrowed so far.

Params

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Leg(,)"

Result

Legs

func Legs(symbol string) int

Legs returns how many components a fusion has.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Legs()"

Result

NewFusion

func NewFusion(cur realm, keyA string, perA int64, keyB string, perB int64, symbol string) string

NewFusion issues a meta-token backed by two registered tokens at a fixed proportion: one smallest unit of the meta-token is always worth `perA` smallest units of A plus `perB` of B. It returns the new token's registry key.

The proportion never changes, and the meta-token is minted and burned only against the real thing, so it cannot drift from its backing or be arbitraged. What it can do is make the pair one transferable object.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "NewFusion" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "NewFusion" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

NewWrapper

func NewWrapper(cur realm, tokenKey, mode, symbol string) string

NewWrapper issues a token wrapping `tokenKey`, a key in grc20reg, under the given mode, and registers it. It returns the new token's own registry key.

`symbol` is yours to choose, must be unique in this realm, and follows the GRC20 rules: 1 to 11 characters of [A-Za-z0-9_-].

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "NewWrapper" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "NewWrapper" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Render

func Render(path string) string

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.Render()"

Result

TotalSupply

func TotalSupply(symbol string) int64

TotalSupply returns how much of `symbol` is outstanding.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/grc20wrapdemo/v0.TotalSupply()"

Result

Transfer

func Transfer(cur realm, symbol string, to address, amount int64)

Transfer moves the caller's own units of `symbol`. A soulbound wrapper refuses here, and nowhere else.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Transfer" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Transfer" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

TransferFrom

func TransferFrom(cur realm, symbol string, from, to address, amount int64)

TransferFrom spends an allowance the caller was granted on `symbol`.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "TransferFrom" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "TransferFrom" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Withdraw

func Withdraw(cur realm, symbol string, amount int64) int64

Withdraw burns `amount` of `symbol` and returns the underlying to the caller. It returns how much came back.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Withdraw" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/grc20wrapdemo/v0" -func "Withdraw" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx