@coinweb/contract-kit
Interfaces
- CallContext
- Context
- ContractHandlers
- CwebCall
- CwebCallRefResolved
- CwebTake
- GL2Transaction
- GenericClaim
- GenericClaimKey
- GenericIssuedClaim
- ResolvedContractRefV0
- ResolvedRead
- ResolvedTake
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
Name | Type | Description |
---|---|---|
context | Context | The transaction context. |
Returns
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
Name | Type | Description |
---|---|---|
end? | OrdJson | The end of the range. |
start? | OrdJson | The 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
Name | Type |
---|---|
ComputationBlockContract | HashId |
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
Name | Type |
---|---|
onFailure? | PreparedCallInfo |
onSuccess | PreparedCallInfo |
Defined in
contract_info.d.ts:32
Continuations
Ƭ Continuations: Object
Represents the structure of the Continuations type.
Type declaration
Name | Type |
---|---|
callStack | Continuation [] |
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
Name | Type | Description |
---|---|---|
contract_input | ContractCallInput | The input to the contract call. |
contract_ref | ContractRef | A 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
Name | Type | Description |
---|---|---|
authenticated | boolean | Whether the call is authenticated. |
cost | HexString | The cost of the call. |
data | any | The 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
Name | Type |
---|---|
authenticated | AuthInfo |
providedCweb | number |
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
Name | Type | Description |
---|---|---|
FromSmartContract | ContractId | The 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
Name | Type |
---|---|
explicit | ContractTree |
stored | CwebRead [] |
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
Name | Type |
---|---|
UnVerified | unknown |
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
Name | Type | Description |
---|---|---|
Verified | GenericIssuedClaim | The 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
Name | Type |
---|---|
Explicit | FileDescription [] |
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
Name | Type |
---|---|
name | string |
path | FilePath |
Defined in
contract_ref.d.ts:19
FilePath
Ƭ FilePath: Object
File path as a sequence of path segments.
Type declaration
Name | Type |
---|---|
path | string [] |
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
Name | Type |
---|---|
CallOp | T |
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
Name | Type |
---|---|
DataOp | T |
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
Name | Type |
---|---|
ReadOp | T |
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
Name | Type |
---|---|
StoreOp | T |
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
Name | Type |
---|---|
TakeOp | T |
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
Name | Type | Description |
---|---|---|
context | Context | The 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
Name | Type |
---|---|
methodArgs | any [] |
methodName | string |
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
Name | Type | Description |
---|---|---|
Continue | { tx : L2TxPrepared } | Represents a continuation of a transaction. |
Continue.tx | L2TxPrepared | The prepared L2 transaction. |
Defined in
operations/transaction.d.ts:6
NewTxJump
Ƭ NewTxJump: Object
Type declaration
Name | Type | Description |
---|---|---|
Jump | { shard : NetworkName ; tx : L2TxPrepared } | Represents a jump to a new shard. |
Jump.shard | NetworkName | The name of the network shard to jump to. |
Jump.tx | L2TxPrepared | The 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
Name | Type |
---|---|
contractArgs | PreparedOperation [] |
contractInfo | ContractInfo |
methodInfo | MethodInfo |
ref | ContractRefV0 |
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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the claims to read. |
key_first_part | OrdJson | The first part of the key for the claims to read. |
max_count | number | The maximum number of claims to read. |
range | ClaimRange | The 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
Name | Type | Description |
---|---|---|
input_id | HashId | This 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_txid | HashId | The 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
Name | Type |
---|---|
Claim | { issuer : ClaimIssuer ; key : GenericClaimKey } |
Claim.issuer | ClaimIssuer |
Claim.key | GenericClaimKey |
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
Name | Type |
---|---|
auth | ContractId |
payload | unknown |
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
Name | Type | Description |
---|---|---|
context | Context | The context to add the continuation to. |
newContinuation | Continuation | The 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
Name | Type | Description |
---|---|---|
contract_module | ContractHandlers | Contract module containing the method. |
handler | MethodCallback | The 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
Name | Type | Description |
---|---|---|
contract_module | ContractHandlers | Contract module containing the method. |
methodName | string | The name of the method. |
handler | MethodCallback | The 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
Name | Type | Description |
---|---|---|
handler | MethodCallback | The method callback to wrap. |
provider | AuthProvider | The function that provides authentication. |
Returns
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
Returns
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
Name | Type | Description |
---|---|---|
handler | MethodCallback | The method callback to wrap. |
Returns
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
Name | Type | Description |
---|---|---|
base64 | string | The 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
Name | Type | Description |
---|---|---|
numberOfArguments | number | The number of arguments for the call. |
contractId | string | The ID of the contract to call. |
Returns
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
Name | Type | Description |
---|---|---|
numberOfArguments | number | The number of arguments for the call. |
contractId | ContractRef | The ID of the contract to call. |
Returns
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
Name | Type | Description |
---|---|---|
firstPart | unknown | The first part of the key. This can be arbitrary JSON. |
secondPart | unknown | The second part of the key. This can be arbitrary JSON. |
Returns
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
Name | Type | Description |
---|---|---|
ops | PreparedOperation [] | The operations for the transaction. |
Returns
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
Name | Type | Description |
---|---|---|
ref | ContractRefV0 | A reference to the contract. |
cost | number | The cost of the call. |
method | string | The method to call. |
data | any [] | The data for the call. |
authenticated | boolean | Whether the call is authenticated. |
Returns
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
Name | Type | Description |
---|---|---|
ref | ContractRef | A reference to the contract. |
cost | number | The cost of the call. |
data | any | The data for the call. |
authenticated | boolean | Whether the call is authenticated. |
Returns
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
Name | Type | Description |
---|---|---|
contractId | ContractId | The contract ID of the smart contract. |
Returns
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
Name | Type | Description |
---|---|---|
issuer | ContractIssuer | The issuer of the contract. |
explicit | ContractTree | The explicit contract tree. |
Returns
The contract reference.
Defined in
contract_ref.d.ts:88
dataUnverified
▸ dataUnverified(content
):
GData
<CwebData
>
Creates an unverified data operation.
Parameters
Name | Type | Description |
---|---|---|
content | unknown | The content to be unverified. |
Returns
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
Name | Type | Description |
---|---|---|
claim | GenericClaim | The claim to be verified. |
issuer | ClaimIssuer | The issuer of the claim. |
Returns
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
Name | Type | Description |
---|---|---|
contract_module | ContractHandlers | Contract 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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
Returns
The authentication data.
Defined in
contract_info.d.ts:103
extractCall
▸ extractCall(op
): CwebCallRefResolved
| null
Extracts the call operation from a resolved operation.
Parameters
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
context | L2TxResolved | The 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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
Returns
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
Returns
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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
context | Context | The context of execution. |
Returns
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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type |
---|---|
authInfo | AuthInfo |
Returns
Defined in
auth.d.ts:33
genericClaim
▸ genericClaim(key
, body
, fees
):
GenericClaim
Function to create a claim structure.
Parameters
Name | Type | Description |
---|---|---|
key | GenericClaimKey | The key of the claim. This is a unique identifier for the claim. |
body | unknown | The body of the claim. This can be arbitrary JSON. |
fees | string | The fees stored in the claim. These are CWEB which can later be reclaimed. |
Returns
Defined in
claims.d.ts:65
genericIssuedClaim
▸ genericIssuedClaim(issuer
, content
):
GenericIssuedClaim
Function to create a generic issued claim.
Parameters
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the claim. This is the entity that created the claim. |
content | GenericClaim | The content of the claim. This is a GenericClaim which includes a key, a body, and stored fees. |
Returns
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
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
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The context of the transaction. |
arg | number | The index of the argument. |
Returns
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The context of the transaction. |
Returns
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
Returns
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
Name | Type | Description |
---|---|---|
options | SelfRegisterOptions | The options to use for getting the explicit files. |
Returns
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
Name | Type | Description |
---|---|---|
context | Context | The 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
Name | Type | Description |
---|---|---|
contract_module | ContractHandlers | Contract module containing the method. |
methodName | string | The name of the method. |
Returns
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
Name | Type | Description |
---|---|---|
context | Context | The 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
Name | Type | Description |
---|---|---|
context | Context | The 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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The context transaction to get the call from. |
Returns
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
Name | Type | Description |
---|---|---|
path | string | The 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
Name | Type | Description |
---|---|---|
contextCall | CallContext | The call context. |
Returns
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
Name | Type | Description |
---|---|---|
hasherIssuer | ClaimIssuer | The hasher contract. This is the smart contract that has the files stored and typically the data-hasher is the smart contract for this. |
hashes | readonly [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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The 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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The context transaction to get the claim from. |
issuer | ClaimIssuer | The issuer of the claim. |
Returns
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
Name | Type | Description |
---|---|---|
hexString | string | The 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
Name | Type | Description |
---|---|---|
data | CwebData | The 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
Name | Type | Description |
---|---|---|
data | CwebData | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
op | ResolvedOperation | The 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
Name | Type | Description |
---|---|---|
reference | ResolvedContractRef | The 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
Name | Type | Description |
---|---|---|
parent | ClaimIssuer | The 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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The transaction context. |
contextCall | CallContext | The 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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The 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
Name | Type | Description |
---|---|---|
ops | PreparedOperation [] | The operations for the transaction. |
shard | string | The name of the network shard to jump to. |
Returns
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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the Cweb. |
amount | number | The amount of Cweb to pass. |
Returns
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
Name | Type | Description |
---|---|---|
resolved | ContractTreeResolved | The resolved contract tree. |
Returns
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
Name | Type | Description |
---|---|---|
info | PreparedCallInfo | The call info to prepare the call with. |
continuations? | Continuations | - |
Returns
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
Name | Type | Description |
---|---|---|
contextTx | L2TxResolved | The 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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the claim to read. |
key | GenericClaimKey | The key of the claim to read. |
Returns
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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the claim to read. |
key | GenericClaimKey | The key of the claim to read. |
Returns
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
Name | Type | Description |
---|---|---|
path | string | The 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
Name | Type | Description |
---|---|---|
issuer | ClaimIssuer | The issuer of the claim. |
registerEntry | RegisterEntry | The entry to register. |
Returns
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
Name | Type | Description |
---|---|---|
handler | MethodCallback | The method callback to wrap. |
Returns
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
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
Name | Type | Description |
---|---|---|
context | Context | context of execution |
Returns
The self registration options.
Defined in
registration.d.ts:76
store
▸ store(claim
):
GStore
<CwebStore
>
Creates a store operation.
Parameters
Name | Type | Description |
---|---|---|
claim | GenericClaim | The claim to be stored. |
Returns
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
Name | Type | Description |
---|---|---|
binaryString | string | The binary string to convert. |
Returns
Uint8Array
The Uint8Array representation of the binary string.
Defined in
utils.d.ts:43
take
Creates a take operation.
Parameters
Name | Type | Description |
---|---|---|
key | GenericClaimKey | The key of the claim to take. |
Returns
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
Name | Type | Description |
---|---|---|
amount | number | The number to convert. |
Returns
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
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
Name | Type | Description |
---|---|---|
content | Uint8Array | The Uint8Array to convert. |
Returns
The Base64 representation of the Uint8Array.
Defined in
utils.d.ts:31
uint8ToHex
▸ uint8ToHex(uint8
): HexString
Converts a Uint8Array to a hexadecimal string.
Parameters
Name | Type | Description |
---|---|---|
uint8 | Uint8Array | The Uint8Array to convert. |
Returns
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
Name | Type | Description |
---|---|---|
handler | MethodCallback | The method callback to wrap. |
Returns
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
Name | Type | Description |
---|---|---|
content | NewTx [] | The content to write to the file in JSON format. |
Returns
void
Defined in
context.d.ts:84