Skip to main content

@coinweb/contract-kit

Interfaces

Type Aliases

AuthInfo

Ƭ AuthInfo: GenericIssuedClaim | null

Type for the authentication information. It can be a generic issued claim or null.

Defined in

context.d.ts:51


AuthProvider

Ƭ AuthProvider: (context: Context) => User

Type definition for a function that provides authentication.

Type declaration

▸ (context): User

Parameters
NameTypeDescription
contextContextThe transaction context.
Returns

User

Defined in

wrappers.d.ts:8


Base64String

Ƭ Base64String: string

Defined in

utils.d.ts:4


ClaimIssuer

Ƭ ClaimIssuer: ContractIssuer | "Parser" | "Aggregator" | "L2BlockInfoProvider" | "AggregatedStatisticProvider" | "TxLogProvider" | "UnfinishedTxProvider" | "StakingStateProvider" | "StakingStatisticsProvider"

Type for a claim issuer. A claim issuer can be a contract issuer or one of several built-in providers that create claims.

Defined in

claim_issuer.d.ts:15


ClaimRange

Ƭ ClaimRange: Object

Represents a range of claims in the database.

Type declaration

NameTypeDescription
end?OrdJsonThe end of the range.
start?OrdJsonThe start of the range.

Defined in

operations/read.d.ts:20


CompResources

Ƭ CompResources: "SmallWasmInstance"

Represents the computational resources used by a call

Defined in

operations/call.d.ts:8


ComputationBlockContract

Ƭ ComputationBlockContract: Object

Type for a computation block contract. A computation block contract is identified by a hash ID.

Type declaration

NameType
ComputationBlockContractHashId

Defined in

contract_id.d.ts:7


Continuation

Ƭ Continuation: Object

Continuations in a contract call. These are the call operations a smart contract is asked to emit if it succeeds or fails.

This can be compared to a Promise's success and failure paths. Multiple are allowed in order to invoke parallel behavior.

Type declaration

NameType
onFailure?PreparedCallInfo
onSuccessPreparedCallInfo

Defined in

contract_info.d.ts:32


Continuations

Ƭ Continuations: Object

Represents the structure of the Continuations type.

Type declaration

NameType
callStackContinuation[]

Defined in

contract_info.d.ts:39


ContractCall

Ƭ ContractCall: Object

Type for a contract call. This includes the input to the call and a reference to the contract.

Type declaration

NameTypeDescription
contract_inputContractCallInputThe input to the contract call.
contract_refContractRefA reference to the contract.

Defined in

contract_call.d.ts:18


ContractCallInput

Ƭ ContractCallInput: Object

Type for the input to a contract call. This includes whether the call is authenticated, the cost of the call, and the data for the call.

Type declaration

NameTypeDescription
authenticatedbooleanWhether the call is authenticated.
costHexStringThe cost of the call.
dataanyThe data for the call.

Defined in

contract_call.d.ts:7


ContractId

Ƭ ContractId: LegacyContractId | ContractIdV0

Type for a contract ID. A contract ID can be a legacy contract ID or a version 0 contract ID.

Defined in

contract_id.d.ts:24


ContractIdV0

Ƭ ContractIdV0: HashId

Version 0 contract ID. A version 0 contract ID is the hash of the virtual file system for the smart contract, computed using a specific algorithm.

Defined in

contract_id.d.ts:19


ContractInfo

Ƭ ContractInfo: Object

Type for basic contract information.

Type declaration

NameType
authenticatedAuthInfo
providedCwebnumber

Defined in

contract_info.d.ts:76


ContractIssuer

Ƭ ContractIssuer: Object

Type for a contract issuer. A contract issuer is identified by the contract ID.

Type declaration

NameTypeDescription
FromSmartContractContractIdThe contract ID of the issuer.

Defined in

claim_issuer.d.ts:7


ContractRef

Ƭ ContractRef: ContractRefV0 | LegacyContractId

Type for a contract reference. A contract reference can be a contract reference version 0 or a legacy contract ID.

Defined in

contract_ref.d.ts:75


ContractRefV0

Ƭ ContractRefV0: Object

Type for a contract reference version 0. This represents how to construct the virtual file system (VFS) for the contract.

There are two ways to do this, either by referencing stored claims that include the VFS information, or explicitly by providing raw data in the form of a [ContractTree].

The explicit approach is typically used when first invoking a contract (see the self registration system), potentially combined with also using stored claims for parts of the VFS that can be reused from other parts of the system.

Note: The contract id is a function of the resolved version of the contract reference, the [ResolvedContractRefV0].

Type declaration

NameType
explicitContractTree
storedCwebRead[]

Defined in

contract_ref.d.ts:67


ContractTree

Ƭ ContractTree: [FileDescription, HexString][]

Type for a contract tree. This is the virtual file system for a smart contract expressed as paths mapped to hashes.

For a deployed smart contract, the hashes are typically stored as claims by the data-hasher smart contract.

Defined in

contract_ref.d.ts:30


ContractTreeResolved

Ƭ ContractTreeResolved: [FileDescription, Uint8Array][]

Type for a resolved contract tree. A resolved contract tree the same virtual file system mapping as the [ContractTree], but contains the actual file contents.

Defined in

contract_ref.d.ts:36


CwebData

Ƭ CwebData: DataVerified | DataUnverified

Defined in

operations/data.d.ts:28


CwebRead

Ƭ CwebRead: SingleClaimRead | RangeClaimRead

Represents a request to read claims.

Defined in

operations/read.d.ts:42


CwebStore

Ƭ CwebStore: GenericClaim

Type alias for a claim that is to be stored

Defined in

operations/store.d.ts:5


DataUnverified

Ƭ DataUnverified: Object

An unverified claim, free form data

Type declaration

NameType
UnVerifiedunknown

Defined in

operations/data.d.ts:25


DataVerified

Ƭ DataVerified: Object

Represents data that has been verified. This means that the claim's issuer is who it is supposed to be. Verified claims cannot be duplicated by a non-issuer contract, but they can be passed along to other child transactions.

The integrity of verified claims is checked by the Coinweb VM, i.e. a smart contract will fail if it produces child transaction that contains invalid verified claims (passed along duplicated verified claims or forged verified claims).

Type declaration

NameTypeDescription
VerifiedGenericIssuedClaimThe verified claim

Defined in

operations/data.d.ts:18


ExplicitOption

Ƭ ExplicitOption: Object

Explicit list of files that should be used to construct the virtual file system and be put in the RegisterEntry by the self-register smart contract.

Type declaration

NameType
ExplicitFileDescription[]

Defined in

registration.d.ts:21


FileDescription

Ƭ FileDescription: Object

Type for a file description. A file description includes a name and a file path.

Type declaration

NameType
namestring
pathFilePath

Defined in

contract_ref.d.ts:19


FilePath

Ƭ FilePath: Object

File path as a sequence of path segments.

Type declaration

NameType
pathstring[]

Defined in

contract_ref.d.ts:13


GCall

Ƭ GCall<T>: Object

Represents an operation to invoke a smart contract.

Type parameters

Name
T

Type declaration

NameType
CallOpT

Defined in

operations/generics.d.ts:30


GData

Ƭ GData<T>: Object

Represents data passed alongside a chain of transactions. This is commonly used as input for a smart contract.

Type parameters

Name
T

Type declaration

NameType
DataOpT

Defined in

operations/generics.d.ts:5


GOperation

Ƭ GOperation<DataType, ReadType, TakeType, StoreType, CallType>: GData<DataType> | GRead<ReadType> | GTake<TakeType> | GStore<StoreType> | GCall<CallType>

Represents a generic operation that can be one of several types.

Type parameters

Name
DataType
ReadType
TakeType
StoreType
CallType

Defined in

operations/generics.d.ts:36


GRead

Ƭ GRead<T>: Object

Represents database lookups.

Type parameters

Name
T

Type declaration

NameType
ReadOpT

Defined in

operations/generics.d.ts:11


GStore

Ƭ GStore<T>: Object

Represents an operation to store a claim owned by the transaction issuer to the database.

Type parameters

Name
T

Type declaration

NameType
StoreOpT

Defined in

operations/generics.d.ts:24


GTake

Ƭ GTake<T>: Object

Represents an operation to remove a claim owned by the transaction issuer from the database, and add the claim to the DB. If the claim doesn't exist, the transaction fails.

Type parameters

Name
T

Type declaration

NameType
TakeOpT

Defined in

operations/generics.d.ts:18


HashId

Ƭ HashId: string

Defined in

utils.d.ts:5


HexString

Ƭ HexString: string

Defined in

utils.d.ts:3


L2TxPrepared

Ƭ L2TxPrepared: GL2Transaction<PreparedOperation>

Represents a L2 transaction that has been prepared for execution. This means that all operations in the transaction have been prepared.

Defined in

operations/operation.d.ts:22


L2TxResolved

Ƭ L2TxResolved: GL2Transaction<ResolvedOperation>

Represents a L2 transaction that has been resolved. This means that all operations in the transaction have been resolved.

Defined in

operations/operation.d.ts:27


LegacyContractId

Ƭ LegacyContractId: "EcdsaContract" | "FailContract" | "ConstantContract" | "DelayContract" | "DataContract" | ComputationBlockContract | "PaymentCheckContract" | "JumpContract" | "AnyOfContract" | "AntiReplayContract"

Type for a legacy contract ID. A legacy contract ID can be one of several predefined contracts or a computation block contract.

Defined in

contract_id.d.ts:14


LegacyContractRef

Ƭ LegacyContractRef: LegacyContractId

Type for a legacy contract reference. A legacy contract reference is a reference to a contract that is built into the coinweb system.

Defined in

contract_ref.d.ts:9


MethodCallback

Ƭ MethodCallback: (context: Context) => NewTx[]

Represents a method function in a smart contract. A method gets the transaction context and returns a list of new transactions to be executed by the Coinweb VM.

Type declaration

▸ (context): NewTx[]

Parameters
NameTypeDescription
contextContextThe transaction context.
Returns

NewTx[]

Defined in

method.d.ts:37


MethodInfo

Ƭ MethodInfo: Object

Represents information about a method. A method, by convention, is dispatched to based on the method name indicated in a data op (see getMethodArguments) when invoking the smart contract.

Type declaration

NameType
methodArgsany[]
methodNamestring

Defined in

method.d.ts:26


NetworkName

Ƭ NetworkName: string

Defined in

utils.d.ts:7


NewTx

Ƭ NewTx: NewTxContinue | NewTxJump

Represents a new transaction that can either continue or jump to a new shard.

Defined in

operations/transaction.d.ts:23


NewTxContinue

Ƭ NewTxContinue: Object

Type declaration

NameTypeDescription
Continue{ tx: L2TxPrepared }Represents a continuation of a transaction.
Continue.txL2TxPreparedThe prepared L2 transaction.

Defined in

operations/transaction.d.ts:6


NewTxJump

Ƭ NewTxJump: Object

Type declaration

NameTypeDescription
Jump{ shard: NetworkName ; tx: L2TxPrepared }Represents a jump to a new shard.
Jump.shardNetworkNameThe name of the network shard to jump to.
Jump.txL2TxPreparedThe prepared L2 transaction.

Defined in

operations/transaction.d.ts:13


OrdJson

Ƭ OrdJson: unknown

Defined in

utils.d.ts:6


PreparedCallInfo

Ƭ PreparedCallInfo: Object

A call to be emitted on success or failure of a smart contract.

Type declaration

NameType
contractArgsPreparedOperation[]
contractInfoContractInfo
methodInfoMethodInfo
refContractRefV0

Defined in

contract_info.d.ts:15


PreparedOperation

Ƭ PreparedOperation: GOperation<CwebData, CwebRead, CwebTake, CwebStore, CwebCall>

Represents an operation that has been prepared for execution. This means that all necessary data for the operation has been gathered and the operation is ready to be executed.

Defined in

operations/operation.d.ts:17


RangeClaimRead

Ƭ RangeClaimRead: Object

Represents a request to read a range of claims from the database.

Type declaration

NameTypeDescription
issuerClaimIssuerThe issuer of the claims to read.
key_first_partOrdJsonThe first part of the key for the claims to read.
max_countnumberThe maximum number of claims to read.
rangeClaimRangeThe range of the claims to read.

Defined in

operations/read.d.ts:29


RegisterEntry

Ƭ RegisterEntry: [FileDescription, SingleClaimRead][]

The contents of a claim representing a registered claim.

This specific claim structure is understood by the call operation which will execute the SingleClaimRead operations and build the virtual file system for the smart contract.

Defined in

registration.d.ts:15


ResolvedContractRef

Ƭ ResolvedContractRef: LegacyContractRef | ResolvedContractRefV0

Type for a resolved contract reference. A resolved contract reference can be a legacy contract reference or a resolved contract reference version 0.

Defined in

contract_ref.d.ts:50


ResolvedOperation

Ƭ ResolvedOperation: GOperation<CwebData, ResolvedRead, ResolvedTake, CwebStore, CwebCallRefResolved>

Represents an operation that has been resolved. This means that all references in the operation have been replaced with their actual values.

Defined in

operations/operation.d.ts:11


SelfRegisterOptions

Ƭ SelfRegisterOptions: ExplicitOption | "ExplicitAll"

The options accepted by the self-register smart contract.

Defined in

registration.d.ts:27


SignedAtTxOrigin

Ƭ SignedAtTxOrigin: [SigningTxIds, unknown]

This type represents both a User (a smart contract + payload), and history information. Index 1 of the array, together with the issuer of a claim that contains this data, can be used to construct an identifying User that is used as the account owner in various settings.

The first element in the array represents "from where did this come from", which is usually used to create claims that represent what happened.

For example, to know which transfers have successfully completed, use the [SigningTxIds] part and put it in a claim, if the transfer did complete successfully

Defined in

auth.d.ts:28


SigningTxIds

Ƭ SigningTxIds: Object

Type declaration

NameTypeDescription
input_idHashIdThis is hash of [SignedPayload]. It can be computed on the frontend for any tx, e.g. including for cweb-less or wrapped in jumps. This is in contrast to l2_txid which cannot be calculated in some cases on the client side.
l2_txidHashIdThe transaction ID on the L2 network.

Defined in

auth.d.ts:4


SingleClaimRead

Ƭ SingleClaimRead: Object

Represents a request to read a single claim from the database.

Type declaration

NameType
Claim{ issuer: ClaimIssuer ; key: GenericClaimKey }
Claim.issuerClaimIssuer
Claim.keyGenericClaimKey

Defined in

operations/read.d.ts:9


TxContext

Ƭ TxContext: L2TxResolved

Type for the context of a transaction. It includes all resolved operations in the transaction.

Defined in

context.d.ts:46


User

Ƭ User: Object

Represents a user in the system.

For example, the ECDSA contract creates Users where the auth is its contract id and the payload is the pubkey. Other smart contract, such as DAOs or new signature schemes can also create a User, allowing them to hold funds in the tokenization block or interact with other smart contracts using the User concept.

Type declaration

NameType
authContractId
payloadunknown

Defined in

method.d.ts:14

Variables

DEFAULT_HANDLER_NAME

Const DEFAULT_HANDLER_NAME: "DEFAULT"

Defined in

utils.d.ts:1


SELF_REGISTER_HANDLER_NAME

Const SELF_REGISTER_HANDLER_NAME: "SELF-REGISTER"

Defined in

utils.d.ts:2

Functions

addContinuation

addContinuation(context, newContinuation): void

Adds a new continuation to the context.

Parameters

NameTypeDescription
contextContextThe context to add the continuation to.
newContinuationContinuationThe new continuation to add.

Returns

void

Defined in

contract_info.d.ts:48


addDefaultMethodHandler

addDefaultMethodHandler(contract_module, handler): void

Adds a default method handler. This handler will be called for the "DEFAULT" method name.

Parameters

NameTypeDescription
contract_moduleContractHandlersContract module containing the method.
handlerMethodCallbackThe method callback to add as the default handler.

Returns

void

Defined in

method.d.ts:72


addMethodHandler

addMethodHandler(contract_module, methodName, handler): void

Adds a method handler for a specific method name.

Parameters

NameTypeDescription
contract_moduleContractHandlersContract module containing the method.
methodNamestringThe name of the method.
handlerMethodCallbackThe method callback to add.

Returns

void

Defined in

method.d.ts:65


authWhitelistWrapper

authWhitelistWrapper(handler, provider): MethodCallback

Wraps a method callback to ensure that it is authenticated by whitelist user

Parameters

NameTypeDescription
handlerMethodCallbackThe method callback to wrap.
providerAuthProviderThe function that provides authentication.

Returns

MethodCallback

A new method callback that throws an error if the call is not authenticated by provider user

Defined in

wrappers.d.ts:21


authenticated

authenticated(contextTx): AuthInfo

Function to get the authentication information from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

AuthInfo

The authentication information.

Throws

Will throw an error if the provided authentication DataOp for contract execution is not found.

Defined in

contract_info.d.ts:69


authenticatedWrapper

authenticatedWrapper(handler): MethodCallback

Wraps a method callback to ensure that it is authenticated.

Parameters

NameTypeDescription
handlerMethodCallbackThe method callback to wrap.

Returns

MethodCallback

A new method callback that throws an error if the call is not authenticated.

Defined in

wrappers.d.ts:27


base64ToUint8

base64ToUint8(base64): Uint8Array

Converts a Base64 string to a Uint8Array.

Parameters

NameTypeDescription
base64stringThe Base64 string to convert.

Returns

Uint8Array

The Uint8Array representation of the Base64 string.

Defined in

utils.d.ts:37


call

call(numberOfArguments, contractId): GCall<CwebCall>

Creates a call operation with the given number of arguments and contract ID.

Parameters

NameTypeDescription
numberOfArgumentsnumberThe number of arguments for the call.
contractIdstringThe ID of the contract to call.

Returns

GCall<CwebCall>

A call operation with the given number of arguments and contract ID.

Defined in

operations/call.d.ts:32


callLegacy

callLegacy(numberOfArguments, contractId): GCall<CwebCall>

Creates a legacy call operation with the given number of arguments and contract ID.

Parameters

NameTypeDescription
numberOfArgumentsnumberThe number of arguments for the call.
contractIdContractRefThe ID of the contract to call.

Returns

GCall<CwebCall>

A legacy call operation with the given number of arguments and contract ID.

Deprecated

Use call instead.

Defined in

operations/call.d.ts:42


claimKey

claimKey(firstPart, secondPart): GenericClaimKey

Function to create a key for a generic claim.

Parameters

NameTypeDescription
firstPartunknownThe first part of the key. This can be arbitrary JSON.
secondPartunknownThe second part of the key. This can be arbitrary JSON.

Returns

GenericClaimKey

Defined in

claims.d.ts:58


continueTx

continueTx(ops): NewTxContinue

Creates a new transaction that is the continuation transaction that the invoker of the smart contract asked to be invoked.

This is somewhat similar to invoking the "then" or "catch" attached to a Promise.

Parameters

NameTypeDescription
opsPreparedOperation[]The operations for the transaction.

Returns

NewTxContinue

A new transaction that continues with the given operations.

Defined in

operations/transaction.d.ts:34


contractCall

contractCall(ref, cost, method, data, authenticated): ContractCall

Function to create a contract call.

Parameters

NameTypeDescription
refContractRefV0A reference to the contract.
costnumberThe cost of the call.
methodstringThe method to call.
dataany[]The data for the call.
authenticatedbooleanWhether the call is authenticated.

Returns

ContractCall

A ContractCall object.

Defined in

contract_call.d.ts:34


contractCallLegacy

contractCallLegacy(ref, cost, data, authenticated): ContractCall

Function to create a contract call. This is the legacy version of contractCall.

Parameters

NameTypeDescription
refContractRefA reference to the contract.
costnumberThe cost of the call.
dataanyThe data for the call.
authenticatedbooleanWhether the call is authenticated.

Returns

ContractCall

A ContractCall object.

Deprecated

Use contractCall instead.

Defined in

contract_call.d.ts:46


contractIssuer

contractIssuer(contractId): ContractIssuer

Function to create a contract issuer for a smart contract.

Parameters

NameTypeDescription
contractIdContractIdThe contract ID of the smart contract.

Returns

ContractIssuer

A contract issuer with the given contract ID.

Defined in

claim_issuer.d.ts:22


contractRef

contractRef(issuer, explicit): ContractRefV0

Function to create a contract reference.

Parameters

NameTypeDescription
issuerContractIssuerThe issuer of the contract.
explicitContractTreeThe explicit contract tree.

Returns

ContractRefV0

The contract reference.

Defined in

contract_ref.d.ts:88


dataUnverified

dataUnverified(content): GData<CwebData>

Creates an unverified data operation.

Parameters

NameTypeDescription
contentunknownThe content to be unverified.

Returns

GData<CwebData>

A data operation with the unverified content.

Defined in

operations/data.d.ts:43


dataVerified

dataVerified(claim, issuer): GData<CwebData>

Creates a verified data operation.

Parameters

NameTypeDescription
claimGenericClaimThe claim to be verified.
issuerClaimIssuerThe issuer of the claim.

Returns

GData<CwebData>

A data operation with the verified claim.

Defined in

operations/data.d.ts:36


executeHandler

executeHandler(contract_module): void

Executes the handler for the method specified in the transaction context. The results (new transactions) are written to the result file.

Parameters

NameTypeDescription
contract_moduleContractHandlersContract module containing the method.

Returns

void

Defined in

method.d.ts:86


extractAuthData

extractAuthData(contextTx): GenericClaim

Function to extract the authentication data from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

GenericClaim

The authentication data.

Defined in

contract_info.d.ts:103


extractCall

extractCall(op): CwebCallRefResolved | null

Extracts the call operation from a resolved operation.

Parameters

NameTypeDescription
opResolvedOperationThe resolved operation to extract from.

Returns

CwebCallRefResolved | null

The call operation if it exists, null otherwise.

Defined in

operations/call.d.ts:56


extractContinuations

extractContinuations(context): Continuations | null | undefined

Function to get the continuations from a transaction context.

Parameters

NameTypeDescription
contextL2TxResolvedThe transaction context.

Returns

Continuations | null | undefined

The continuations, if no continuations are provided, then return undefined. null means empty continuations.

Defined in

contract_info.d.ts:91


extractContractArgs

extractContractArgs(contextTx): ResolvedOperation[]

Function to extract the contract arguments from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

ResolvedOperation[]

The contract arguments.

Defined in

contract_info.d.ts:97


extractContractInfo

extractContractInfo(contextTx): ContractInfo

Function to extract basic contract information from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

ContractInfo

The basic contract information.

Defined in

contract_info.d.ts:85


extractDataUnverified

extractDataUnverified(op): unknown | null

Extracts the unverified data from a resolved operation.

Parameters

NameTypeDescription
opResolvedOperationThe resolved operation to extract from.

Returns

unknown | null

The unverified data if it exists, null otherwise.

Defined in

operations/data.d.ts:78


extractDataVerified

extractDataVerified(op): GenericIssuedClaim | null

Extracts the verified data from a resolved operation.

Parameters

NameTypeDescription
opResolvedOperationThe resolved operation to extract from.

Returns

GenericIssuedClaim | null

The verified data if it exists, null otherwise.

Defined in

operations/data.d.ts:71


extractMethodInfo

extractMethodInfo(context): MethodInfo

Extracts the method information from the given transaction context.

Parameters

NameTypeDescription
contextContextThe context of execution.

Returns

MethodInfo

The method information, including the method name and arguments.

Defined in

method.d.ts:92


extractRead

extractRead(op): GenericIssuedClaim[] | null

Extracts the results of a read operation from a resolved operation.

Parameters

NameTypeDescription
opResolvedOperationThe resolved operation to extract from.

Returns

GenericIssuedClaim[] | null

The results of the read operation if it exists, null otherwise.

Defined in

operations/read.d.ts:78


extractTake

extractTake(op): GenericClaim | null

Extracts the result of a take operation from a resolved operation.

Parameters

NameTypeDescription
opResolvedOperationThe resolved operation to extract from.

Returns

GenericClaim | null

The result of the take operation if it exists, null otherwise.

Defined in

operations/take.d.ts:34


extractUser

extractUser(authInfo): User

Parameters

NameType
authInfoAuthInfo

Returns

User

Defined in

auth.d.ts:33


genericClaim

genericClaim(key, body, fees): GenericClaim

Function to create a claim structure.

Parameters

NameTypeDescription
keyGenericClaimKeyThe key of the claim. This is a unique identifier for the claim.
bodyunknownThe body of the claim. This can be arbitrary JSON.
feesstringThe fees stored in the claim. These are CWEB which can later be reclaimed.

Returns

GenericClaim

Defined in

claims.d.ts:65


genericIssuedClaim

genericIssuedClaim(issuer, content): GenericIssuedClaim

Function to create a generic issued claim.

Parameters

NameTypeDescription
issuerClaimIssuerThe issuer of the claim. This is the entity that created the claim.
contentGenericClaimThe content of the claim. This is a GenericClaim which includes a key, a body, and stored fees.

Returns

GenericIssuedClaim

Defined in

claims.d.ts:71


getContextCall

getContextCall(): CallContext

Function to get the context of a call which is located at the well known location context/call.json. See CallContext for the layout of this file.

Returns

CallContext

The context of the call.

Defined in

context.d.ts:58


getContextTx

getContextTx(): TxContext

Function to get the context of a transaction which is located at the well known location context/tx.json. See TxContext for the layout of this file.

Returns

TxContext

The context of the transaction in JSON format.

Defined in

context.d.ts:73


getContractArgument

getContractArgument(contextTx, arg): ResolvedOperation

Function to get a specific argument of a contract from the context of a transaction.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe context of the transaction.
argnumberThe index of the argument.

Returns

ResolvedOperation

The argument of the contract at the specified index as a ResolvedOperation.

Defined in

context.d.ts:102


getContractArguments

getContractArguments(contextTx): ResolvedOperation[]

Function to get the arguments of a contract from the context of a transaction.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe context of the transaction.

Returns

ResolvedOperation[]

The arguments of the contract as an array of ResolvedOperation.

Defined in

context.d.ts:92


getContractId

getContractId(contextTx): HashId

Function to get the contract ID from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

HashId

The contract ID.

Throws

Will throw an error if the resolved reference is not version 0.

Defined in

contract_id.d.ts:32


getExplicitFiles

getExplicitFiles(options): ContractTreeResolved

Reads files from the file system into a ContractTreeResolved structure. Either an explicit list of files are read, or everything under contract/*.

Parameters

NameTypeDescription
optionsSelfRegisterOptionsThe options to use for getting the explicit files.

Returns

ContractTreeResolved

The explicit files as a ContractTreeResolved.

Defined in

registration.d.ts:70


getMethodArguments

getMethodArguments(context): any[]

Retrieves the arguments of a method from the given transaction context.

Parameters

NameTypeDescription
contextContextThe context of execution.

Returns

any[]

The arguments of the method.

Throws

Will throw an error if the arguments are invalid.

Defined in

method.d.ts:52


getMethodHandler

getMethodHandler(contract_module, methodName): MethodCallback

Retrieves the method handler for a specific method name.

Parameters

NameTypeDescription
contract_moduleContractHandlersContract module containing the method.
methodNamestringThe name of the method.

Returns

MethodCallback

The method callback for the specified method name.

Throws

Will throw an error if no handler is specified for the method name.

Defined in

method.d.ts:80


getMethodName

getMethodName(context): string

Retrieves the name of the method from the given transaction context.

Parameters

NameTypeDescription
contextContextThe transaction context.

Returns

string

The name of the method.

Defined in

method.d.ts:58


getNextContinuation

getNextContinuation(context): Continuation | null

Get the next continuation from the context's call stack.

Parameters

NameTypeDescription
contextContextThe context containing the call stack.

Returns

Continuation | null

The next continuation from the call stack, or null if the stack is empty.

Defined in

contract_info.d.ts:55


getOriginalCall

getOriginalCall(contextTx): CwebCallRefResolved

Gets the original call operation from the context transaction.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe context transaction to get the call from.

Returns

CwebCallRefResolved

The original call operation.

Throws

Will throw an error if the call operation is not found.

Defined in

operations/call.d.ts:64


getParameters

getParameters(path): any

Function to get the parameters from a file located at the specified path.

Parameters

NameTypeDescription
pathstringThe path of the file.

Returns

any

The parameters from the file in JSON format.

Defined in

context.d.ts:65


getParent

getParent(contextCall): ClaimIssuer

Function to get the parent of a call context. If the transaction that held the currently executing CallOp was extracted from L1, it will be "Parser", otherwise, the issuer will be the smart contract that created the transaction that held this CallOp.

Parameters

NameTypeDescription
contextCallCallContextThe call context.

Returns

ClaimIssuer

The issuer of the call context.

Defined in

claim_issuer.d.ts:32


getRegisterEntry

getRegisterEntry(hasherIssuer, hashes): [FileDescription, SingleClaimRead][]

Constructs an array of tuples, where each tuple contains a FileDescription and a claim read specification, a SingleClaimRead. This array represents the registration entry for a smart contract. Each read is of a claim written by the data-hasher contract by the convention used by the self-registration system, but the call operation supports reading claims from any smart contract.

Parameters

NameTypeDescription
hasherIssuerClaimIssuerThe hasher contract. This is the smart contract that has the files stored and typically the data-hasher is the smart contract for this.
hashesreadonly [FileDescription, string][]An array of tuples, where each tuple contains a FileDescription and a HashId. The FileDescription describes the file in the virtual file system and the HashId is the unique identifier for the file's content. By convention, the HashId is the key used by the data-hasher to store the file contents.

Returns

[FileDescription, SingleClaimRead][]

An array of tuples, where each tuple contains a FileDescription and a SingleClaimRead. The SingleClaimRead is a claim that can be used to read the file's content from the virtual file system.

Defined in

registration.d.ts:96


getSkipAuthClaim

getSkipAuthClaim(contextTx): boolean

Function to get the skip authentication claim from a transaction context.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.

Returns

boolean

The skip authentication claim.

Throws

Will throw an error if the provided authentication DataOp for contract execution is not found.

Defined in

contract_info.d.ts:62


getVerifiedClaimFrom

getVerifiedClaimFrom(contextTx, issuer): GenericClaim

Gets the verified claim from the context transaction.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe context transaction to get the claim from.
issuerClaimIssuerThe issuer of the claim.

Returns

GenericClaim

The verified claim.

Throws

Will throw an error if the issued claim is not found.

Defined in

operations/data.d.ts:87


hexToUint8

hexToUint8(hexString): Uint8Array

Converts a hexadecimal string to a Uint8Array.

Parameters

NameTypeDescription
hexStringstringThe hexadecimal string to convert. It should be prefixed by "0x".

Returns

Uint8Array

The Uint8Array representation of the hexadecimal string.

Defined in

utils.d.ts:25


isDataUnverified

isDataUnverified(data): data is DataUnverified

Checks if the data is unverified.

Parameters

NameTypeDescription
dataCwebDataThe data to check.

Returns

data is DataUnverified

True if the data is unverified, false otherwise.

Defined in

operations/data.d.ts:64


isDataVerified

isDataVerified(data): data is DataVerified

Checks if the data is verified.

Parameters

NameTypeDescription
dataCwebDataThe data to check.

Returns

data is DataVerified

True if the data is verified, false otherwise.

Defined in

operations/data.d.ts:57


isResolvedCall

isResolvedCall(op): op is GCall<CwebCallRefResolved>

Checks if the operation is a resolved call operation.

Parameters

NameTypeDescription
opResolvedOperationThe operation to check.

Returns

op is GCall<CwebCallRefResolved>

True if the operation is a resolved call operation, false otherwise.

Defined in

operations/call.d.ts:49


isResolvedData

isResolvedData(op): op is GData<CwebData>

Checks if the operation is a resolved data operation.

Parameters

NameTypeDescription
opResolvedOperationThe operation to check.

Returns

op is GData<CwebData>

True if the operation is a resolved data operation, false otherwise.

Defined in

operations/data.d.ts:50


isResolvedRead

isResolvedRead(op): op is GRead<ResolvedRead>

Checks if the operation is a resolved read operation.

Parameters

NameTypeDescription
opResolvedOperationThe operation to check.

Returns

op is GRead<ResolvedRead>

True if the operation is a resolved read operation, false otherwise.

Defined in

operations/read.d.ts:71


isResolvedStore

isResolvedStore(op): op is GStore<GenericClaim>

Checks if the operation is a resolved store operation.

Parameters

NameTypeDescription
opResolvedOperationThe operation to check.

Returns

op is GStore<GenericClaim>

True if the operation is a resolved store operation, false otherwise.

Defined in

operations/store.d.ts:19


isResolvedTake

isResolvedTake(op): op is GTake<ResolvedTake>

Checks if the operation is a resolved take operation.

Parameters

NameTypeDescription
opResolvedOperationThe operation to check.

Returns

op is GTake<ResolvedTake>

True if the operation is a resolved take operation, false otherwise.

Defined in

operations/take.d.ts:27


isResolvedV0

isResolvedV0(reference): reference is ResolvedContractRefV0

Function to check if a contract reference is resolved (version 0).

Parameters

NameTypeDescription
referenceResolvedContractRefThe contract reference to check.

Returns

reference is ResolvedContractRefV0

True if the contract reference is resolved version 0, false otherwise.

Defined in

contract_ref.d.ts:94


isRootContract

isRootContract(parent): boolean

Function to check if a claim issuer is a root contract.

Parameters

NameTypeDescription
parentClaimIssuerThe claim issuer.

Returns

boolean

True if the claim issuer is a root contract, false otherwise.

Defined in

claim_issuer.d.ts:39


isSelfCall

isSelfCall(contextTx, contextCall): boolean

Function to check if a call is a self call, i.e. the parent of this call is ourselves.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe transaction context.
contextCallCallContextThe call context.

Returns

boolean

True if the call is a self call, false otherwise.

Defined in

claim_issuer.d.ts:55


isSmartContractIssuer

isSmartContractIssuer(issuer): issuer is ContractIssuer

Function to check if a claim issuer is a smart contract issuer.

Parameters

NameTypeDescription
issuerClaimIssuerThe claim issuer.

Returns

issuer is ContractIssuer

True if the claim issuer is a smart contract issuer, false otherwise.

Defined in

claim_issuer.d.ts:46


jumpTx

jumpTx(ops, shard): NewTxJump

Creates a jump to a new shard.

Parameters

NameTypeDescription
opsPreparedOperation[]The operations for the transaction.
shardstringThe name of the network shard to jump to.

Returns

NewTxJump

A new transaction that jumps to the specified shard with the given operations.

Defined in

operations/transaction.d.ts:42


passCwebFrom

passCwebFrom(issuer, amount): GData<CwebData>

Passes Cweb from the issuer.

Parameters

NameTypeDescription
issuerClaimIssuerThe issuer of the Cweb.
amountnumberThe amount of Cweb to pass.

Returns

GData<CwebData>

A data operation with the verified claim of the passed Cweb.

Defined in

operations/transaction.d.ts:50


prepareContractTree

prepareContractTree(resolved): ContractTree

Function to prepare a contract tree for a resolved contract.

Parameters

NameTypeDescription
resolvedContractTreeResolvedThe resolved contract tree.

Returns

ContractTree

The prepared contract tree.

Defined in

contract_ref.d.ts:81


preparedCall

preparedCall(info, continuations?): PreparedOperation[]

Prepares a call operation with the given call info.

Parameters

NameTypeDescription
infoPreparedCallInfoThe call info to prepare the call with.
continuations?Continuations-

Returns

PreparedOperation[]

An array of prepared operations.

Defined in

operations/call.d.ts:71


providedCweb

providedCweb(contextTx): number

Function to get the provided CWEB for contract execution from the context of a transaction. This function returns the contract argument number 2 as a number, and by convention, this argument contains the amount of CWEB the contract can use.

Note: the return value of this function is unrelated to the actual CWEB available to the smart contract. This amount is not directly accessible to the smart contract.

Parameters

NameTypeDescription
contextTxL2TxResolvedThe context of the transaction.

Returns

number

The provided CWEB for contract execution as a number.

Defined in

context.d.ts:116


read

read(issuer, key): GRead<CwebRead>

Creates a read operation for a single claim.

Parameters

NameTypeDescription
issuerClaimIssuerThe issuer of the claim to read.
keyGenericClaimKeyThe key of the claim to read.

Returns

GRead<CwebRead>

A read operation for the specified claim.

Defined in

operations/read.d.ts:56


readClaim

readClaim(issuer, key): SingleClaimRead

Creates a single claim read request.

Parameters

NameTypeDescription
issuerClaimIssuerThe issuer of the claim to read.
keyGenericClaimKeyThe key of the claim to read.

Returns

SingleClaimRead

A single claim read request for the specified claim.

Defined in

operations/read.d.ts:64


readFileToBuffer

readFileToBuffer(path, bufLength?): Uint8Array

Reads a file and returns its content as a Uint8Array.

Parameters

NameTypeDescription
pathstringThe path of the file to read.
bufLength?number-

Returns

Uint8Array

The content of the file as a Uint8Array.

Defined in

registration.d.ts:63


registerClaimTx

registerClaimTx(issuer, registerEntry): NewTx

Creates a new transaction for registering a self registration claim.

The self-registration system is a mechanism implemented partly by the smart contract itself, and partly by the cweb-tool when deploying smart contracts to Coinweb.

In the self-registration system, the smart contract is expected to have a method handler for "SELF-REGISTER" that creates this transaction to register the claim that can be used to create the VFS for itself.

...
kit.addMethodHandler(kit.SELF_REGISTER_HANDLER_NAME, selfRegisterHandler);
...

Read more about self-registration at

Parameters

NameTypeDescription
issuerClaimIssuerThe issuer of the claim.
registerEntryRegisterEntryThe entry to register.

Returns

NewTx

A new transaction for registering the claim.

Defined in

registration.d.ts:57


selfCallWrapper

selfCallWrapper(handler): MethodCallback

Wraps a method callback to ensure that it can only be called by the contract itself.

Parameters

NameTypeDescription
handlerMethodCallbackThe method callback to wrap.

Returns

MethodCallback

A new method callback that throws an error if the call is not from the contract itself.

Defined in

wrappers.d.ts:14


selfRegisterKey

selfRegisterKey(): GenericClaimKey

The claim key for the registration claim from the self-register smart contract.

Returns

GenericClaimKey

A GenericClaimKey for self registration.

Defined in

registration.d.ts:32


selfRegisterOptions

selfRegisterOptions(context): SelfRegisterOptions

Returns the self registration options from the given transaction context.

Parameters

NameTypeDescription
contextContextcontext of execution

Returns

SelfRegisterOptions

The self registration options.

Defined in

registration.d.ts:76


store

store(claim): GStore<CwebStore>

Creates a store operation.

Parameters

NameTypeDescription
claimGenericClaimThe claim to be stored.

Returns

GStore<CwebStore>

A store operation with the given claim.

Defined in

operations/store.d.ts:12


stringToUint8

stringToUint8(binaryString): Uint8Array

Converts a binary string to a Uint8Array.

Parameters

NameTypeDescription
binaryStringstringThe binary string to convert.

Returns

Uint8Array

The Uint8Array representation of the binary string.

Defined in

utils.d.ts:43


take

take(key): GTake<CwebTake>

Creates a take operation.

Parameters

NameTypeDescription
keyGenericClaimKeyThe key of the claim to take.

Returns

GTake<CwebTake>

A take operation with the given key.

Defined in

operations/take.d.ts:20


toHex

toHex(amount): HexString

Converts a number to a hexadecimal string.

Parameters

NameTypeDescription
amountnumberThe number to convert.

Returns

HexString

The hexadecimal representation of the number (example: "0xdeadbeef").

Defined in

utils.d.ts:13


tokenizationBlockContractId

tokenizationBlockContractId(): ComputationBlockContract

Function to get the contract ID of the tokenization block contract.

Returns

ComputationBlockContract

The contract ID of the tokenization block contract.

Defined in

claim_issuer.d.ts:61


uint8ToBase64

uint8ToBase64(content): Base64String

Converts a Uint8Array to a Base64 string.

Parameters

NameTypeDescription
contentUint8ArrayThe Uint8Array to convert.

Returns

Base64String

The Base64 representation of the Uint8Array.

Defined in

utils.d.ts:31


uint8ToHex

uint8ToHex(uint8): HexString

Converts a Uint8Array to a hexadecimal string.

Parameters

NameTypeDescription
uint8Uint8ArrayThe Uint8Array to convert.

Returns

HexString

The hexadecimal representation of the Uint8Array (example: "0xdeadbeef").

Defined in

utils.d.ts:19


withContinuations

withContinuations(handler): MethodCallback

Wraps a method callback to handle continuations.

Parameters

NameTypeDescription
handlerMethodCallbackThe method callback to wrap.

Returns

MethodCallback

A new method callback that handles continuations.

Defined in

wrappers.d.ts:33


writeToResultFile

writeToResultFile(content): void

Function to write the result of the smart contract to a file located at the well known location output/out.json.

Writing to this file is the only way a smart contract can have external effects, i.e. writing claims, invoking new smart contracts etc. See NewTx for the layout of this file.

Parameters

NameTypeDescription
contentNewTx[]The content to write to the file in JSON format.

Returns

void

Defined in

context.d.ts:84