Skip to main content

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

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 | 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.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