Documentation ¶
Index ¶
- Constants
- func EventEmit(enc *wasmtypes.WasmEncoder)
- func EventHandlersGenerateID() uint32
- func ExportName(index int32, name string)
- func FuncError(ctx ScFuncContext)
- func Log(text string)
- func NewCallParamsProxy(v *ScView) wasmtypes.Proxy
- func NewCallResultsProxy(v *ScView, resultsProxy *wasmtypes.Proxy)
- func NewEventEncoder(topic string) *wasmtypes.WasmEncoder
- func NewParamsProxy() wasmtypes.Proxy
- func NewResultsProxy() wasmtypes.Proxy
- func NewStateProxy() wasmtypes.Proxy
- func Panic(text string)
- func Sandbox(funcNr int32, params []byte) []byte
- func StateDelete(key []byte)
- func StateExists(key []byte) bool
- func StateGet(key []byte) []byte
- func StateSet(key, value []byte)
- func Trace(text string)
- func ViewError(ctx ScViewContext)
- type IEventHandlers
- type ScAssets
- type ScBalances
- type ScDict
- type ScExportMap
- type ScFunc
- func (f *ScFunc) Allowance(allowance *ScTransfer) *ScFunc
- func (f *ScFunc) AllowanceBaseTokens(amount uint64) *ScFunc
- func (f *ScFunc) Call()
- func (f *ScFunc) Delay(seconds uint32) *ScFunc
- func (f *ScFunc) OfContract(hContract wasmtypes.ScHname) *ScFunc
- func (f *ScFunc) Post()
- func (f *ScFunc) PostToChain(chainID wasmtypes.ScChainID)
- func (f *ScFunc) Transfer(transfer *ScTransfer) *ScFunc
- func (f *ScFunc) TransferBaseTokens(amount uint64) *ScFunc
- type ScFuncClientContext
- type ScFuncContext
- type ScFuncContextFunction
- type ScHost
- type ScImmutableDict
- type ScImmutableState
- type ScInitFunc
- type ScSandbox
- func (s ScSandbox) AccountID() wasmtypes.ScAgentID
- func (s ScSandbox) Balance(tokenID wasmtypes.ScTokenID) uint64
- func (s ScSandbox) Balances() *ScBalances
- func (s ScSandbox) ChainOwnerID() wasmtypes.ScAgentID
- func (s ScSandbox) Contract() wasmtypes.ScHname
- func (s ScSandbox) CurrentChainID() wasmtypes.ScChainID
- func (s ScSandbox) FnCall(req *wasmrequests.CallRequest) []byte
- func (s ScSandbox) FnChainID() wasmtypes.ScChainID
- func (s ScSandbox) Log(text string)
- func (s ScSandbox) Panic(text string)
- func (s ScSandbox) Params() *ScImmutableDict
- func (s ScSandbox) RawState() ScImmutableState
- func (s ScSandbox) Require(cond bool, msg string)
- func (s ScSandbox) Results(results wasmtypes.Proxy)
- func (s ScSandbox) Timestamp() uint64
- func (s ScSandbox) Trace(text string)
- func (s ScSandbox) Utility() ScSandboxUtils
- type ScSandboxFunc
- func (s ScSandboxFunc) Allowance() *ScBalances
- func (s ScSandboxFunc) Call(hContract, hFunction wasmtypes.ScHname, params *ScDict, allowance *ScTransfer) *ScImmutableDict
- func (s ScSandboxFunc) Caller() wasmtypes.ScAgentID
- func (s ScSandboxFunc) DeployContract(programHash wasmtypes.ScHash, name string, initParams *ScDict)
- func (s ScSandboxFunc) Entropy() wasmtypes.ScHash
- func (s ScSandboxFunc) EstimateStorageDeposit(fn *ScFunc) uint64
- func (s ScSandboxFunc) Event(buf []byte)
- func (s ScSandboxFunc) FnPost(req *wasmrequests.PostRequest) []byte
- func (s ScSandboxFunc) Minted() ScBalances
- func (s ScSandboxFunc) Post(chainID wasmtypes.ScChainID, hContract, hFunction wasmtypes.ScHname, ...)
- func (s ScSandboxFunc) Random(max uint64) (rnd uint64)
- func (s ScSandboxFunc) RawState() ScState
- func (s ScSandboxFunc) RequestID() wasmtypes.ScRequestID
- func (s ScSandboxFunc) RequestSender() wasmtypes.ScAgentID
- func (s ScSandboxFunc) Send(address wasmtypes.ScAddress, transfer *ScTransfer)
- func (s ScSandboxFunc) TransferAllowed(agentID wasmtypes.ScAgentID, transfer *ScTransfer)
- type ScSandboxUtils
- func (u ScSandboxUtils) Bech32Decode(value string) wasmtypes.ScAddress
- func (u ScSandboxUtils) Bech32Encode(addr wasmtypes.ScAddress) string
- func (u ScSandboxUtils) BlsAddressFromPubKey(pubKey []byte) wasmtypes.ScAddress
- func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte)
- func (u ScSandboxUtils) BlsValidSignature(data, pubKey, signature []byte) bool
- func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddress
- func (u ScSandboxUtils) Ed25519ValidSignature(data, pubKey, signature []byte) bool
- func (u ScSandboxUtils) HashBlake2b(value []byte) wasmtypes.ScHash
- func (u ScSandboxUtils) HashKeccak(value []byte) wasmtypes.ScHash
- func (u ScSandboxUtils) HashName(value string) wasmtypes.ScHname
- func (u ScSandboxUtils) HashSha3(value []byte) wasmtypes.ScHash
- func (u ScSandboxUtils) String(value int64) string
- type ScSandboxView
- type ScState
- type ScTransfer
- func NewScTransfer() *ScTransfer
- func ScTransferFromBalances(balances *ScBalances) *ScTransfer
- func ScTransferFromBaseTokens(amount uint64) *ScTransfer
- func ScTransferFromNFT(nftID *wasmtypes.ScNftID) *ScTransfer
- func ScTransferFromTokens(tokenID *wasmtypes.ScTokenID, amount wasmtypes.ScBigInt) *ScTransfer
- type ScView
- type ScViewClientContext
- type ScViewContext
- type ScViewContextFunction
- type TokenAmounts
Constants ¶
const ( // should be aligned to gas.LimitsDefault.MinGasPerRequest MinGasFee = uint64(10_000) StorageDeposit = uint64(20_000) FnAccountID = int32(-1) FnAllowance = int32(-2) FnBalance = int32(-3) FnBalances = int32(-4) FnBlockContext = int32(-5) FnCall = int32(-6) FnCaller = int32(-7) FnChainID = int32(-8) FnChainOwnerID = int32(-9) FnContract = int32(-10) FnDeployContract = int32(-11) FnEntropy = int32(-12) FnEstimateStorageDeposit = int32(-13) FnEvent = int32(-14) FnLog = int32(-15) FnMinted = int32(-16) FnPanic = int32(-17) FnParams = int32(-18) FnPost = int32(-19) FnRequest = int32(-20) FnRequestID = int32(-21) FnRequestSender = int32(-22) FnResults = int32(-23) FnSend = int32(-24) FnStateAnchor = int32(-25) FnTimestamp = int32(-26) FnTrace = int32(-27) FnTransferAllowed = int32(-28) FnUtilsBech32Decode = int32(-29) FnUtilsBech32Encode = int32(-30) FnUtilsBlsAddress = int32(-31) FnUtilsBlsAggregate = int32(-32) FnUtilsBlsValid = int32(-33) FnUtilsEd25519Address = int32(-34) FnUtilsEd25519Valid = int32(-35) FnUtilsHashBlake2b = int32(-36) FnUtilsHashName = int32(-37) FnUtilsHashSha3 = int32(-38) FnUtilsHashKeccak = int32(-39) )
Variables ¶
This section is empty.
Functions ¶
func EventEmit ¶ added in v1.0.3
func EventEmit(enc *wasmtypes.WasmEncoder)
func EventHandlersGenerateID ¶ added in v1.0.3
func EventHandlersGenerateID() uint32
func ExportName ¶
func FuncError ¶
func FuncError(ctx ScFuncContext)
func NewCallParamsProxy ¶
func NewCallResultsProxy ¶
func NewEventEncoder ¶
func NewEventEncoder(topic string) *wasmtypes.WasmEncoder
func NewParamsProxy ¶
func NewResultsProxy ¶ added in v1.0.3
func NewStateProxy ¶
func StateDelete ¶
func StateDelete(key []byte)
func StateExists ¶
func ViewError ¶
func ViewError(ctx ScViewContext)
Types ¶
type IEventHandlers ¶ added in v1.0.3
type IEventHandlers interface { CallHandler(topic string, dec *wasmtypes.WasmDecoder) ID() uint32 }
type ScAssets ¶
type ScAssets struct { BaseTokens uint64 NativeTokens TokenAmounts Nfts map[wasmtypes.ScNftID]bool }
func NewScAssets ¶ added in v0.3.0
func (*ScAssets) Balances ¶
func (a *ScAssets) Balances() ScBalances
type ScBalances ¶
type ScBalances struct {
// contains filtered or unexported fields
}
func (*ScBalances) Balance ¶
func (b *ScBalances) Balance(tokenID *wasmtypes.ScTokenID) wasmtypes.ScBigInt
func (*ScBalances) BaseTokens ¶ added in v0.3.0
func (b *ScBalances) BaseTokens() uint64
func (*ScBalances) Bytes ¶ added in v0.3.0
func (b *ScBalances) Bytes() []byte
func (*ScBalances) IsEmpty ¶ added in v0.3.0
func (b *ScBalances) IsEmpty() bool
func (*ScBalances) NftIDs ¶ added in v0.3.0
func (b *ScBalances) NftIDs() []*wasmtypes.ScNftID
func (*ScBalances) TokenIDs ¶ added in v0.3.0
func (b *ScBalances) TokenIDs() []*wasmtypes.ScTokenID
type ScDict ¶
type ScDict struct {
ScImmutableDict
}
func ScDictFromBytes ¶ added in v1.0.3
func (*ScDict) Immutable ¶
func (d *ScDict) Immutable() *ScImmutableDict
type ScExportMap ¶
type ScExportMap struct { Names []string Funcs []ScFuncContextFunction Views []ScViewContextFunction }
func (*ScExportMap) Dispatch ¶ added in v1.0.3
func (m *ScExportMap) Dispatch(index int32) *ScExportMap
general entrypoint for the host to call any SC function the host will pass the index of one of the entry points that was provided by on_load during SC initialization
func (*ScExportMap) Export ¶ added in v0.3.6
func (m *ScExportMap) Export(exportName func(index int32, name string))
constructs the symbol export context for the on_load function
type ScFunc ¶
type ScFunc struct { ScView // contains filtered or unexported fields }
func NewScFunc ¶
func NewScFunc(ctx ScFuncClientContext, hContract, hFunction wasmtypes.ScHname) *ScFunc
func (*ScFunc) Allowance ¶ added in v0.3.0
func (f *ScFunc) Allowance(allowance *ScTransfer) *ScFunc
Allowance defines the assets that the SC is allowed to take out of the caller account on the chain. Note that that does not mean that the SC will take them all. The SC needs to be able to take them explicitly. Otherwise the assets will stay in the caller’s account.
func (*ScFunc) AllowanceBaseTokens ¶ added in v0.3.0
func (*ScFunc) PostToChain ¶
func (*ScFunc) Transfer ¶
func (f *ScFunc) Transfer(transfer *ScTransfer) *ScFunc
Transfer defines the assets that are transferred from the caller’s L1 address to his L2 account. The SC cannot touch these unless explicitly allowed. Transfer only comes into play with on-ledger requests. Off-ledger requests cannot do a transfer.
func (*ScFunc) TransferBaseTokens ¶ added in v0.3.0
type ScFuncClientContext ¶ added in v1.0.3
type ScFuncClientContext interface { ScViewClientContext FnPost(req *wasmrequests.PostRequest) []byte }
type ScFuncContext ¶
type ScFuncContext struct {
ScSandboxFunc
}
smart contract func sandbox interface
func (ScFuncContext) ClientContract ¶ added in v1.0.3
func (ctx ScFuncContext) ClientContract(hContract wasmtypes.ScHname) wasmtypes.ScHname
func (ScFuncContext) Host ¶
func (ctx ScFuncContext) Host() ScHost
type ScFuncContextFunction ¶
type ScFuncContextFunction func(ScFuncContext)
type ScHost ¶
type ScHost interface { ExportName(index int32, name string) Sandbox(funcNr int32, params []byte) []byte StateDelete(key []byte) StateExists(key []byte) bool StateGet(key []byte) []byte StateSet(key, value []byte) }
func ConnectHost ¶
type ScImmutableDict ¶
type ScImmutableDict struct {
// contains filtered or unexported fields
}
func (*ScImmutableDict) Exists ¶
func (d *ScImmutableDict) Exists(key []byte) bool
func (*ScImmutableDict) Get ¶
func (d *ScImmutableDict) Get(key []byte) []byte
type ScImmutableState ¶
type ScImmutableState struct{}
func (ScImmutableState) Exists ¶
func (d ScImmutableState) Exists(key []byte) bool
func (ScImmutableState) Get ¶
func (d ScImmutableState) Get(key []byte) []byte
type ScInitFunc ¶
type ScInitFunc struct {
ScView
}
func NewScInitFunc ¶
func NewScInitFunc(ctx ScFuncClientContext, hContract, hFunction wasmtypes.ScHname) *ScInitFunc
func (*ScInitFunc) Call ¶
func (f *ScInitFunc) Call()
func (*ScInitFunc) OfContract ¶
func (f *ScInitFunc) OfContract(hContract wasmtypes.ScHname) *ScInitFunc
func (*ScInitFunc) Params ¶
func (f *ScInitFunc) Params() []interface{}
type ScSandbox ¶
type ScSandbox struct{}
func (ScSandbox) Balances ¶
func (s ScSandbox) Balances() *ScBalances
access the current balances for all assets
func (ScSandbox) ChainOwnerID ¶
retrieve the agent id of the owner of the chain this contract lives on
func (ScSandbox) CurrentChainID ¶ added in v0.3.0
retrieve the chain id of the chain this contract lives on
func (ScSandbox) FnCall ¶ added in v1.0.3
func (s ScSandbox) FnCall(req *wasmrequests.CallRequest) []byte
func (ScSandbox) Params ¶
func (s ScSandbox) Params() *ScImmutableDict
retrieve parameters passed to the smart contract function that was called
func (ScSandbox) RawState ¶
func (s ScSandbox) RawState() ScImmutableState
func (ScSandbox) Timestamp ¶
deterministic timestamp in nanosecond fixed at the moment of calling the smart contract
func (ScSandbox) Utility ¶
func (s ScSandbox) Utility() ScSandboxUtils
access diverse utility functions
type ScSandboxFunc ¶
type ScSandboxFunc struct {
ScSandbox
}
func (ScSandboxFunc) Allowance ¶ added in v0.3.0
func (s ScSandboxFunc) Allowance() *ScBalances
access the allowance assets
func (ScSandboxFunc) Call ¶
func (s ScSandboxFunc) Call(hContract, hFunction wasmtypes.ScHname, params *ScDict, allowance *ScTransfer) *ScImmutableDict
calls a smart contract function
func (ScSandboxFunc) Caller ¶
func (s ScSandboxFunc) Caller() wasmtypes.ScAgentID
retrieve the agent id of the caller of the smart contract
func (ScSandboxFunc) DeployContract ¶
func (s ScSandboxFunc) DeployContract(programHash wasmtypes.ScHash, name string, initParams *ScDict)
deploys a smart contract
func (ScSandboxFunc) Entropy ¶
func (s ScSandboxFunc) Entropy() wasmtypes.ScHash
returns random entropy data for current request.
func (ScSandboxFunc) EstimateStorageDeposit ¶ added in v0.3.0
func (s ScSandboxFunc) EstimateStorageDeposit(fn *ScFunc) uint64
func (ScSandboxFunc) Event ¶
func (s ScSandboxFunc) Event(buf []byte)
signals an event on the node that external entities can subscribe to
func (ScSandboxFunc) FnPost ¶ added in v1.0.3
func (s ScSandboxFunc) FnPost(req *wasmrequests.PostRequest) []byte
func (ScSandboxFunc) Minted ¶
func (s ScSandboxFunc) Minted() ScBalances
retrieve the assets that were minted in this transaction
func (ScSandboxFunc) Post ¶
func (s ScSandboxFunc) Post(chainID wasmtypes.ScChainID, hContract, hFunction wasmtypes.ScHname, params *ScDict, allowance, transfer ScTransfer, delay uint32)
Post (delayed) posts a SC function request
func (ScSandboxFunc) Random ¶
func (s ScSandboxFunc) Random(max uint64) (rnd uint64)
generates a random value from 0 to max (exclusive max) using a deterministic RNG
func (ScSandboxFunc) RawState ¶
func (s ScSandboxFunc) RawState() ScState
func (ScSandboxFunc) RequestID ¶
func (s ScSandboxFunc) RequestID() wasmtypes.ScRequestID
retrieve the request id of this transaction
func (ScSandboxFunc) RequestSender ¶ added in v0.3.0
func (s ScSandboxFunc) RequestSender() wasmtypes.ScAgentID
retrieve the request sender of this transaction
func (ScSandboxFunc) Send ¶
func (s ScSandboxFunc) Send(address wasmtypes.ScAddress, transfer *ScTransfer)
Send transfers SC assets to the specified address
func (ScSandboxFunc) TransferAllowed ¶ added in v0.3.0
func (s ScSandboxFunc) TransferAllowed(agentID wasmtypes.ScAgentID, transfer *ScTransfer)
TransferAllowed transfers allowed assets from caller to the specified account
type ScSandboxUtils ¶
type ScSandboxUtils struct{}
func (ScSandboxUtils) Bech32Decode ¶ added in v0.3.0
func (u ScSandboxUtils) Bech32Decode(value string) wasmtypes.ScAddress
Bech32Decode decodes the specified bech32-encoded string value to its original address
func (ScSandboxUtils) Bech32Encode ¶ added in v0.3.0
func (u ScSandboxUtils) Bech32Encode(addr wasmtypes.ScAddress) string
Bech32Encode encodes the specified address to a bech32-encoded string
func (ScSandboxUtils) BlsAddressFromPubKey ¶
func (u ScSandboxUtils) BlsAddressFromPubKey(pubKey []byte) wasmtypes.ScAddress
func (ScSandboxUtils) BlsAggregateSignatures ¶
func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte)
func (ScSandboxUtils) BlsValidSignature ¶
func (u ScSandboxUtils) BlsValidSignature(data, pubKey, signature []byte) bool
func (ScSandboxUtils) Ed25519AddressFromPubKey ¶
func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddress
func (ScSandboxUtils) Ed25519ValidSignature ¶
func (u ScSandboxUtils) Ed25519ValidSignature(data, pubKey, signature []byte) bool
func (ScSandboxUtils) HashBlake2b ¶
func (u ScSandboxUtils) HashBlake2b(value []byte) wasmtypes.ScHash
hashes the specified value bytes using Blake2b hashing and returns the resulting 32-byte hash
func (ScSandboxUtils) HashKeccak ¶ added in v1.0.3
func (u ScSandboxUtils) HashKeccak(value []byte) wasmtypes.ScHash
hashes the specified value bytes using Keccak hashing and returns the resulting 32-byte hash
func (ScSandboxUtils) HashName ¶ added in v1.0.3
func (u ScSandboxUtils) HashName(value string) wasmtypes.ScHname
hashes the specified value bytes using Blake2b hashing and returns the resulting 32-byte hash
func (ScSandboxUtils) HashSha3 ¶
func (u ScSandboxUtils) HashSha3(value []byte) wasmtypes.ScHash
hashes the specified value bytes using SHA3 hashing and returns the resulting 32-byte hash
func (ScSandboxUtils) String ¶
func (u ScSandboxUtils) String(value int64) string
converts an integer to its string representation
type ScSandboxView ¶
type ScSandboxView struct {
ScSandbox
}
func (ScSandboxView) Call ¶
func (s ScSandboxView) Call(hContract, hFunction wasmtypes.ScHname, params *ScDict) *ScImmutableDict
calls a smart contract view
type ScState ¶
type ScState struct {
ScImmutableState
}
func (ScState) Immutable ¶
func (d ScState) Immutable() ScImmutableState
type ScTransfer ¶ added in v0.3.0
type ScTransfer struct {
ScBalances
}
func NewScTransfer ¶
func NewScTransfer() *ScTransfer
create a new transfer object ready to add token transfers
func ScTransferFromBalances ¶ added in v1.0.3
func ScTransferFromBalances(balances *ScBalances) *ScTransfer
create a new transfer object from a balances object
func ScTransferFromBaseTokens ¶ added in v1.0.3
func ScTransferFromBaseTokens(amount uint64) *ScTransfer
create a new transfer object and initialize it with the specified amount of base tokens
func ScTransferFromNFT ¶ added in v1.0.3
func ScTransferFromNFT(nftID *wasmtypes.ScNftID) *ScTransfer
create a new transfer object and initialize it with the specified NFT
func ScTransferFromTokens ¶ added in v1.0.3
func ScTransferFromTokens(tokenID *wasmtypes.ScTokenID, amount wasmtypes.ScBigInt) *ScTransfer
create a new transfer object and initialize it with the specified token transfer
func (*ScTransfer) AddNFT ¶ added in v0.3.0
func (t *ScTransfer) AddNFT(nftID *wasmtypes.ScNftID)
func (*ScTransfer) Bytes ¶ added in v0.3.0
func (t *ScTransfer) Bytes() []byte
type ScView ¶
type ScView struct {
// contains filtered or unexported fields
}
type ScViewClientContext ¶ added in v1.0.3
type ScViewClientContext interface { ClientContract(hContract wasmtypes.ScHname) wasmtypes.ScHname FnCall(req *wasmrequests.CallRequest) []byte FnChainID() wasmtypes.ScChainID }
type ScViewContext ¶
type ScViewContext struct {
ScSandboxView
}
smart contract view sandbox interface
func (ScViewContext) ClientContract ¶ added in v1.0.3
func (ctx ScViewContext) ClientContract(hContract wasmtypes.ScHname) wasmtypes.ScHname
type ScViewContextFunction ¶
type ScViewContextFunction func(ScViewContext)