Realm detail
test_mtk
gno.land/r/g1g2xdc0erd3ppcgaf9a8n5pe45ytg3mff2jsfh6/test_mtk
Indexed deployment identity with independently loaded latest RPC source, functions, and Render.
Indexed deployment
Identity
- Package path
- gno.land/r/g1g2xdc0erd3ppcgaf9a8n5pe45ytg3mff2jsfh6/test_mtk
- Block
- 291824
- Deployed (UTC)
- Transaction
- gfpR6CtaXyEvK7dQ7mNe6iJGCuCAb102mSd52pBpg2g=
Latest RPC state
Source
package test_mtk
import (
"strings"
"gno.land/p/demo/tokens/grc20"
ownable "gno.land/p/nt/ownable/v0"
ufmt "gno.land/p/nt/ufmt/v0"
"gno.land/r/demo/defi/grc20reg"
)
const tokenID = 0
var (
token *grc20.Token
privateLedger *grc20.PrivateLedger
userTeller grc20.Teller
// ВАЖНО: замените на СВОЙ g1-адрес — тогда владельцем будете вы
owner = ownable.NewWithAddress("g1g2xdc0erd3ppcgaf9a8n5pe45ytg3mff2jsfh6")
)
func init(cur realm) {
token, privateLedger = grc20.NewToken("My Test Token", "MTT", 6, tokenID, cur)
userTeller = privateLedger.CallerTeller()
// сразу чеканим себе стартовый запас
privateLedger.Mint(owner.Owner(), 1_000_000_000_000) // 1,000,000 MTK (6 знаков)
grc20reg.Register(cross(cur), token, "")
}
func TotalSupply() int64 {
return userTeller.TotalSupply()
}
func BalanceOf(owner address) int64 {
return userTeller.BalanceOf(owner)
}
func Allowance(owner, spender address) int64 {
return userTeller.Allowance(owner, spender)
}
func Transfer(cur realm, to address, amount int64) {
checkErr(userTeller.Transfer(0, cur, to, amount))
}
func Approve(cur realm, spender address, amount int64) {
checkErr(userTeller.Approve(0, cur, spender, amount))
}
func TransferFrom(cur realm, from, to address, amount int64) {
checkErr(userTeller.TransferFrom(0, cur, from, to, amount))
}
// Mint доступен только владельцу — то есть вам
func Mint(cur realm, to address, amount int64) {
owner.AssertOwnedBy(cur.Previous().Address())
checkErr(privateLedger.Mint(to, amount))
}
func Burn(cur realm, from address, amount int64) {
owner.AssertOwnedBy(cur.Previous().Address())
checkErr(privateLedger.Burn(from, amount))
}
func Render(path string) string {
parts := strings.Split(path, "/")
c := len(parts)
switch {
case path == "":
return token.RenderHome()
case c == 2 && parts[0] == "balance":
owner := address(parts[1])
balance := userTeller.BalanceOf(owner)
return ufmt.Sprintf("%d\n", balance)
default:
return "404\n"
}
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}Latest RPC state
Exported functions
- TotalSupply() int64
- BalanceOf(owner string) int64
- Allowance(owner string, spender string) int64
- Transfer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, to string, amount int64)
- Approve(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, spender string, amount int64)
- TransferFrom(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, from string, to string, amount int64)
- Mint(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, to string, amount int64)
- Burn(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, from string, amount int64)
- Render(path string) string
Latest RPC state · Realm Render
My Test Token ($MTT)
- Decimals: 6
- Total supply: 1000000000000
- Known accounts: 1