Chain-related
IsOriginCall
func IsOriginCall() bool
Checks if the caller of the function is an EOA. Returns true if caller is an EOA, false otherwise.
Usage
if !std.IsOriginCall() {...}
AssertOriginCall
func AssertOriginCall()
Panics if caller of function is not an EOA.
Usage
std.AssertOriginCall()
CurrentRealmPath
func CurrentRealmPath() string
Returns the path of the realm it is called in.
Usage
realmPath := std.CurrentRealmPath() // gno.land/r/demo/users
GetChainID
func GetChainID() string
Returns the chain ID.
Usage
chainID := std.GetChainID() // dev | test3 | main ...
GetHeight
func GetHeight() int64
Returns the current block number (height).
Usage
height := std.GetHeight()
GetOrigSend
func GetOrigSend() Coins
Returns the Coins
that were sent along with the calling transaction.
Usage
coinsSent := std.GetOrigSend()
GetOrigCaller
func GetOrigCaller() Address
Returns the original signer of the transaction.
Usage
caller := std.GetOrigSend()
GetOrigPkgAddr
func GetOrigPkgAddr() string
Returns the address of the first (entry point) realm/package in a sequence of realm/package calls.
Usage
origPkgAddr := std.GetOrigPkgAddr()
CurrentRealm
func CurrentRealm() Realm
Returns current Realm object.
Usage
currentRealm := std.CurrentRealm()
PrevRealm
func PrevRealm() Realm
Returns the previous caller realm (can be realm or EOA). If caller is am EOA, pkgpath
will be empty.
Usage
prevRealm := std.PrevRealm()
GetCallerAt
func GetCallerAt(n int) Address
Returns the n-th caller of the function, going back in the call trace.
Usage
currentRealm := std.GetCallerAt(1) // returns address of current realm
previousRealm := std.GetCallerAt(2) // returns address of previous realm/caller
std.GetCallerAt(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