Skip to main content

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")

GetChainID

func GetChainID() string

Returns the chain ID.

Usage

chainID := std.GetChainID() // dev | test5 | 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.GetOrigCaller()

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 code or user realm). If caller is a user realm, 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

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 realm
  • coinName 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