Bases
Bases returns every base name this realm issues, in creation order.
Command
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Bases()"
Result
Package nativeify turns a GRC20 into a native coin, which is wugnot run backwards.
wugnot takes GNOT, a coin the bank holds, and issues a GRC20 receipt for it, because a GRC20 can be pulled by a contract and a native coin cannot. This realm takes a GRC20, escrows it, and issues a native denom against it 1:1, because a native coin can do four things a GRC20 cannot:
A native coin cannot be pulled. `banker.SendCoins` refuses any `from` that is not the banker's own realm address, so there is no allowance, no `TransferFrom`, and no way for an AMM, an escrow or a subscription to take what you approved. Everything downstream of `Approve` stops working the moment a coin becomes native. That is not a gap in this realm; it is the property that makes the wrapping worth doing in the other direction.
And the issuer of a native coin can always delete a balance: `RemoveCoin` takes an arbitrary address. This realm never calls it on an address other than its own, Unwrap explains why in detail, and the gnomod.toml explains why this path is public rather than redeployable. Those three together are the entire guarantee. There is no on-chain way to prove a negative about code.
One smallest unit of the underlying is one unit of the coin. Not 10^decimals: the bank has no notion of divisibility, so a token with 6 decimals wrapped here produces a coin counted in the token's own smallest units, and the 6 is carried to `r/moul/x/nativereg` as a display hint and nowhere else.
Solvency is therefore a plain equality that anybody can check without trusting this realm's bookkeeping: the GRC20 balance at this realm's address equals the total supply of the denom. Solvency computes it from both sides.
Play money to try it on: `r/moul/x/grc20faucet/v0`.
Bases returns every base name this realm issues, in creation order.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Bases()"
Denom returns the denom this realm issues for a base name.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Denom()"
IsSolvent reports whether every coin issued for a base name is backed.
It allows escrowed > issued, which is what a donation to this realm's address looks like and cannot hurt anybody, and refuses the reverse.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.IsSolvent()"
Nativeify creates the native counterpart of a GRC20 registered in `r/nt/grc20reg`, and returns its denom. It issues nothing: Wrap does that.
`base` is the part of the denom after the colon, yours to choose, unique in this realm and in the chain's charset. One native denom per underlying token: a second one would double the chain's per-denom storage for no new capability, and realm-denom balances live under their own store keys, which are not gas-metered.
# 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/nativeify/v0" -func "Nativeify" -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/nativeify/v0" -func "Nativeify" -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 lists the pairs. `?<base>` shows one.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Render()"
Solvency returns what is escrowed and what is issued for a base name. They are read from two different places on the chain, the GRC20 ledger and the bank, and this realm's own bookkeeping is not consulted for either: if they ever disagree, the disagreement is the answer.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Solvency()"
TokenKey returns the grc20reg key of the underlying behind a base name.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.TokenKey()"
Underlying returns the underlying token behind a base name, for a caller that wants its name, symbol or decimals.
gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativeify/v0.Underlying()"
Unwrap destroys the native coins attached to this call and releases the same number of underlying GRC20 units to the caller.
This realm holds a `BankerTypeRealmIssue` banker, and `RemoveCoin` takes an arbitrary address, so it could delete the caller's coins directly and save them a flag. It does not, and the reason is worth stating where somebody copying this will read it: a realm whose normal operation is to remove coins from addresses that did not hand them over has no way left to demonstrate that it only ever does so consensually. Every `RemoveCoin` here names this realm's own address, which anybody can check by reading the source, and the coins get to that address the only way a native coin ever moves, by their holder pushing them.
So: attach them.
1-send <amount>/gno.land/r/moul/x/nativeify/v0:<base>
# 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/nativeify/v0" -func "Unwrap" -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/nativeify/v0" -func "Unwrap" -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
Wrap escrows `amount` of the underlying and issues the same number of native coins to the caller.
You must `Approve` this realm's address on the underlying token first, through that token's own realm. Until you do, this realm has no authority over your balance at all, and Wrap fails with "insufficient allowance", which is the system working.
# 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/nativeify/v0" -func "Wrap" -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/nativeify/v0" -func "Wrap" -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