Chain-related
AssertOriginCall
func AssertOriginCall()
Panics if caller of function is not an EOA.
Usage
std.AssertOriginCall()
ChainDomain
func ChainDomain() string
Returns the chain domain. Currently only gno.land
is supported.
Usage
domain := std.ChainDomain() // gno.land
Emit
func Emit(typ string, attrs ...string)
Emits a Gno event. Takes in a string type (event identifier), and an even number of string arguments acting as key-value pairs to be included in the emitted event.
Usage
std.Emit("MyEvent", "myKey1", "myValue1", "myKey2", "myValue2")
ChainID
func ChainID() string
Returns the chain ID.
Usage
chainID := std.ChainID() // dev | test5 | main ...
ChainHeight
func ChainHeight() int64
Returns the current block number (height).
Usage
height := std.ChainHeight()
OriginSend
func OriginSend() Coins
Returns the Coins
that were sent along with the calling transaction.
Usage
coinsSent := std.OriginSend()
OriginCaller
func OriginCaller() Address
Returns the original signer of the transaction.
Usage
caller := std.OriginCaller()
OriginPkgAddress
func OriginPkgAddress() Address
Returns the address of the first (entry point) realm/package in a sequence of realm/package calls.
Usage
originPkgAddr := std.OriginPkgAddress()
CurrentRealm
func CurrentRealm() Realm
Returns current Realm object.
Usage
currentRealm := std.CurrentRealm()
PreviousRealm
func PreviousRealm() Realm
Returns the previous caller realm (can be code or user realm). If caller is a
user realm, pkgpath
will be empty.
Usage
prevRealm := std.PreviousRealm()
CallerAt
func CallerAt(n int) Address
Returns the n-th caller of the function, going back in the call trace.
Usage
currentRealm := std.CallerAt(1) // returns address of current realm
previousRealm := std.CallerAt(2) // returns address of previous realm/caller
std.CallerAt(0) // error, n must be > 0
DerivePkgAddr
func DerivePkgAddr(pkgPath string) Address
Derives the Realm address from its pkgpath
parameter.
Usage
realmAddr := std.DerivePkgAddr("gno.land/r/demo/tamagotchi") // g1a3tu874agjlkrpzt9x90xv3uzncapcn959yte4
CoinDenom
func CoinDenom(pkgPath, coinName string) string
Composes a qualified denomination string from the realm's pkgPath
and the provided coin name, e.g. /gno.land/r/demo/blog:blgcoin
. This method should be used to get fully qualified denominations of coins when interacting with the Banker
module. It can also be used as a method of the Realm
object, Read morehere.
Parameters
pkgPath
string - package path of the realmcoinName
string - The coin name used to build the qualified denomination. Must start with a lowercase letter, followed by 2–15 lowercase letters or digits.
Usage
denom := std.CoinDenom("gno.land/r/demo/blog", "blgcoin") // /gno.land/r/demo/blog:blgcoin