CKSDK Features
Tools
CKSDK includes a small set of utility helpers under CKSDK.tool to handle numeric operations safely and consistently, especially when dealing with cryptocurrency amounts and decimal precision.
Arithmetic
Performs safe arithmetic using string-based inputs to avoid floating-point precision issues.
Supported operations:
+: Addition–: Subtractionx: Multiplication/: Division
const operation = "+"; // Addition
const a = "5.2231";
const b = "6";
const decimal = 4;
const result = CKSDK.tool.arithmetic(operation, a, b, decimal);a,b: Numbers represented as strings.decimal: Number of decimal places to preserve in the result.
NOTE
The return value is always a string.
Decimal to Integer
Converts a decimal string to an integer representation using a fixed number of decimal places (useful for storing values in base units).
const value = "5.2231";
const decimal = 4;
const outputBigInt = true;
const result = CKSDK.tool.dec_to_int(value, decimal, outputBigInt);value: Decimal number as a string (e.g."5.2231").decimal: Number of decimal places (scale factor).outputBigInt: Whentrue, returns aBigInt; when omitted orfalse, returns a string.
This is typically used to convert human-readable amounts into integer base units for storage or on-chain operations.
Integer to Decimal
Converts an integer representation (base units) back into a human-readable decimal string.
const value = "52231";
const decimal = 4;
const result = CKSDK.tool.int_to_dec(value, decimal);value: Integer value as a string (e.g."52231").decimal: Number of decimal places to apply.
NOTE
The return value is always a string.
Pagination filters
CKSDK provides a helper API for constructing filter objects used with the various "List" / "Summary" / "Information" endpoints in the CoKeeps Hot Wallet (e.g. users, destinations, transactions). These filters are exposed under CKSDK.pagination.filters.
Available Filter Groups
The following filter groups are available:
usersdestinationstravelRulesledgertotaluser
poolreviewaccountsmonitortransactionstransferinteractsweepDepositsweepWithdrawalsweepGasStationsweepSignerWalletBasegasStationrebalance
Each group returns an array of filter descriptors, which you can use to build the params object for the corresponding REST API.
Example Transactions -> Transfer Filter
const params = CKSDK.pagination.filters.transactions.transfer;
console.log(params);Example output:
[
{
"key": "tid",
"type": "string",
"text": "Tx ID",
"value": null,
},
{
"key": "uid",
"type": "string",
"text": "UID",
"value": null,
},
// -- Snip --
]Each entry represents a filterable field:
key– The field name to be used in yourparamspayload (e.g.tid,uid).type– Expected value type (see below).text– Human-readable label (useful for UI).value– The current value (initiallynull; you set this before sending the request).
You would typically:
- Retrieve the filter definitions from
CKSDK.pagination.filters..., - Let your UI or backend populate the
valuefield(s), - Build your
paramsobject using the selected filters, and - Send it as
paramsin the relevant paginated REST call (e.g./service/information/transactions/transfer).
Actions
NOTE
Scope: The actions in this section are available to both signer and admin roles.
Approval rule: An admin cannot approve their own actions; approvals must be performed by another admin.
Set Destination Address
For omnibus withdrawals, users must first register a destination address that will be used as the recipient of funds when withdrawing from the omnibus structure. This address (and its associated Travel Rule data, where applicable) is stored and, if required, can be routed through your approval and compliance workflows before any omnibus withdrawal request is processed.
const types = [
{ text: "Self Hosted", value: "self-hosted" },
{ text: "Provider (Exchange / Custodian)", value: "provider" },
];
// Returns a Promise
CKSDK.action.destination({
chain_id: "bitcoin",
address: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
// Travel Rule information
name: "Ahmad Damha",
country: "Malaysia",
caddress: "1, Jalan 2, Taman Tiga, 53100, Kuala Lumpur, Malaysia",
contact: "600-1122334455",
email: "ahmad.damha@email.com",
reference: "This is a test",
type: types[0].value, // "self-hosted"
typeName: "Ledger Hardware Wallet",
// Proof of address ownership (Self-Hosted)
addressSignature: "637b9be6f950135997306976c6dea4d1bc956c17b985194ee7398697949e8b07798eba71eb37becca027ceacd55c1ebc67131a98bf0f30fa8b6ae9c7df42ae0762326431356331376431663263646530343564373331336461616666396437663437613962386364343336373133313661663430633734663330613931643539",
addressSignatureInput: ""
});For type: "self-hosted", you must provide:
addressSignature:Signature digest of the address value signed as a message using the corresponding private key (proof of address ownership).
You may use mechanisms such as WalletConnect to perform this signing.
addressSignatureInput:Public key input required for Ripple or Solana SPL-Token addresses only.
NOTE
Only one destination address can be set per user per chain_id at a time.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"id": "66c56b3e66a0c500120d9237",
}
}Retrieve Deposit Address
If your platform accepts on-chain digital assets (network native or tokens) as funding for your product or service, you can generate a temporary deposit address for each user and chain. These deposit addresses act as placeholders to identify which incoming transfers belong to which user and are intended to be swept into more secure omnibus or multi-signature accounts.
A deposit address is derived from the user's CKSDK authentication credentials and is therefore tied to the current login cryptography. When a user's CKSDK credentials are reset, newly generated deposit addresses will change. However, any previously created deposit addresses remain valid on-chain and can still be swept, in case users continue sending assets to older addresses.
// Returns a Promise
CKSDK.action.generate_deposit({
chain_id: "ethereum",
index: 0 // Optional
});chain_id: Network identifier for the deposit address.index(optional): Integer index (default 0). Use this to generate multiple deposit addresses per chain for the same user.
Admin users with the appropriate permissions can later sweep deposit balances into Holding / omnibus / multi-signature accounts.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"address": "0x391EF99987f60CE0cf3382FE00295B0c1e8DE6b5",
"index": 0
}
}Retrieve Signer Wallet Address
Derive a Signer Wallet address for a user using a label. This is a single-signature account associated with the user, which can also be used as their signer account for smart contracts and transfers.
// Returns a Promise
CKSDK.action.generate_signer_wallet({
chain_id: "solana",
label: "Account 1",
message: "A message to sign for proof of ownership" // Optional
});Your system must maintain and track all label values created by users:
- The same
labelalways generates the same address for a given user. - The same
labelused by different users will generate different addresses (user-unique).
If message is provided:
- The wallet will attempt to sign that message with the account’s private key and return the signature.
- Use with caution: exposing arbitrary message signing to users may lead them to unknowingly sign sensitive data.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"address": "9oZ3kPXx1wmnBuDMqiiyKBFt1KKMVT1gPE92N243dfMj",
"signature": "4923391799a54860d7408aa8b889e126a3fb1af51ba17474d627af35c53f183bf8c7b4e2ea528cc2702afa6646f131eeaa525b5a2194a50002097e2aa1f53903"
}
}Transfer Transaction
NOTE
For Signer Wallets, this method can be configured to require administrator review before the transaction is broadcast to the blockchain. Pending items will appear in List Pending Reviews. Please contact us if you wish to enable this feature.
// Returns a Promise
CKSDK.action.transfer({
chain_id: "solana",
from: "AS1yfbX6dx9dJd8fiey3uc22anb6KGZz6USSB8zmGW92",
to: "J6pZKwXQhbA7WEKKBc2cY7gFSLyAyJNUkpetsZDFTpjp",
amount: "0.5",
memo: "This is a test",
reference_id: "TICKET-123",
estimateFee: false // Optional
});from: Address of the Signer Wallet or a Withdrawal account.to: Destination address. Must match an approved entry in the Read endpoint's destinations.amount: Decimal string. Must not exceed the limits specified by your Read endpoint (limits) and may also be constrained by Dynamic Ledger when applicable.memo: Optional text (max 256 characters).reference_id: Your system-generated reference ID for this transaction.estimateFee: Whentrue, the call returns an estimated fee and does not execute the transaction.
Example response - No Pending Review:
IMPORTANT
If you fail to capture the tid due to connection loss, query List Transactions - transfer using reference_id to obtain the status.
{
"success": true,
"message": "OK",
"rdata": {
"tid": "66c56b0d66a0c500120d9234"
}
}Example response – Pending Review:
If the Pending Review feature is enabled, the action returns a Review ID (rid) instead of a Transaction ID (tid):
{
"success": true,
"message": "OK",
"rdata": {
"rid": "66c56b0d66a0c500120d9234"
}
}NOTE
To verify whether a transaction has been confirmed on-chain, use the Lookup Transaction API and check the blockNumber (or equivalent) in the response.
Example response – Fee estimation:
If estimateFee is true, the response includes an estimated fee in the lowest denomination integer of the native currency:
{
"success": true,
"message": "OK",
"rdata": {
"estimatedFee": "34885913140"
}
}Smart Contract Transaction
IMPORTANT
- For ERC-20 or SPL-Token Token transfer, please use the Transfer Transaction API method instead.
- Only smart contracts deployed or imported within the CoKeeps platform can be interacted with.
// Returns a Promise
CKSDK.action.interact({
chain_id: "ethereum",
from: "0x18682333780a7a2FeBBD0F7Bf6EAb9d37Ae16bFe",
address: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
method: "borrow",
methodArgs: [ "12050" ],
reference_id: "TICKET-124",
estimateFee: false, // Optional
target_chain_id: false // Optional
});from: Address of the Signer Wallet.address: Smart contract address to interact with. The contract must have been approved via the Client Administration platform.method/methodArgs: Function name and argument list as defined in the contract ABI. These can be discovered via the Smart Contract Lookup Interface backend API.reference_id: Your system-generated reference ID for this interaction.estimateFee: Whentrue, returns an estimated gas/fee cost without sending the transaction.target_chain_id: Used in specialised flows (e.g. recovering transfers sent to a token deposit address on the wrong network). Leave asfalsewhen not required.
Example response:
IMPORTANT
If you lose the tid due to connection issues, query List Transactions - interact using reference_id to retrieve the status.
{
"success": true,
"message": "OK",
"rdata": {
"tid": "66d48fe2ebb3b700115fe55b"
}
}NOTE
To confirm on-chain inclusion, use Lookup Transaction and check the block details.
Example response - Fee estimation:
{
"success": true,
"message": "OK",
"rdata": {
"estimatedFee": "8232846"
}
}The estimatedFee is in the lowest denomination integer of the chain's native asset.
Omnibus Withdrawal
This action is used when you operate an omnibus account with Dynamic Ledger enabled and wish to request a withdrawal from the omnibus pool on behalf of a user's ledger balance. The request may be subject to additional approvals and processing steps.
NOTE
This method does not immediately perform the on-chain transaction; it registers a withdrawal request that flows through your configured omnibus / multi-signature process.
// Returns a Promise
CKSDK.action.omnibus_withdraw({
chain_id: "solana",
amount: "1000",
memo: "Test withdraw from Omnibus account",
reference_id: "TICKET-125"
});chain_id: Network associated with the underlying omnibus account.amount: Decimal string. Typically must not exceed:- The user's Dynamic Ledger balance, and/or
- Any business limits defined by your Read endpoint.
memo: Optional text (max 256 characters).reference_id: Your system-generated reference ID for this withdrawal request.
The actual recipient address for the withdrawal is the destination address previously defined and approved via Set Destination Address.
Example response:
IMPORTANT
If you fail to capture the withdrawal id due to a connection issue, query List Transactions for omnibus withdrawals using reference_id to obtain the status.
{
"success": true,
"message": "OK",
"rdata": {
"id": "66c56d6666a0c500120d923b"
}
}Decisions
This section is **exclusive to the admin role.
Approval rule: An admin cannot approve their own actions - approvals must be performed by a different admin.
Approve / Reject Destination Address
A destination address registered via Set Destination Address may require administrative review before it can be used for omnibus withdrawals.
NOTE
Any decision made for a destination address automatically applies to its associated Travel Rule record (if present).
const decisions = [
{ text: "Approve", value: "approve" },
{ text: "Reject", value: "reject" },
];
// Returns a Promise
CKSDK.decide.destination({
_id: "<destination_id>",
decision: decisions[0].value, // "approve"
remark: "Additional information to include",
});_id: Destination ID obtained from List Destinations.decision:"approve"or"reject".remark: Optional for approvals, required whendecisionis"reject".
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"id": "66c5338caf2057001226d679"
}
}Approve / Reject Travel Rule
Admins can explicitly approve or reject Travel Rule entries submitted for a destination.
const decisions = [
{ text: "Approve", value: "approve" },
{ text: "Reject", value: "reject" },
];
// Returns a Promise
CKSDK.decide.travel_rule({
_id: "<travel_rule_id>",
decision: decisions[0].value,
remark: "Additional information to include",
});_id: Travel Rule ID obtained from List Travel Rules.decision:"approve"or"reject".remark: Optional for approvals, required for rejections.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"id": "66b974505e39400012dabd34"
}
}Approve / Reject Transaction Request
This decision flow applies to Dynamic Transaction Pool entries, typically generated by Omnibus Withdrawal requests.
const decisions = [
{ text: "Approve", value: "approve" },
{ text: "Reject", value: "reject" },
];
// Returns a Promise
CKSDK.decide.transaction_request({
_id: "<tx_pool_id>",
from: "AS1yfbX6dx9dJd8fiey3uc22anb6KGZz6USSB8zmGW92",
decision: decisions[0].value,
remark: "Additional information to include",
});_id: Dynamic Transaction Pool ID obtained from Dynamic Transaction Pool – List Transactions.from: The omnibus multi-signature account that will fund the withdrawal.- This value is typically retrieved from Dynamic Transaction Pool – Retrieve Integrated Accounts.
decision:"approve"or"reject".remark: Optional for approvals, required for rejections.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"id": "66c56d6666a0c500120d923b"
}
}Approve / Reject Pending Reviews
When Pending Review is enabled for Signer Wallet transfers, each transfer request can be approved or rejected by an admin via its Review ID.
const decisions = [
{ text: "Approve", value: "approve" },
{ text: "Reject", value: "reject" }
];
// Returns a Promise
CKSDK.decide.review({
_id: "<review_id>",
decision: decisions[0].value,
remark: "Additional information to include",
});_id: Review ID obtained from Information – List Pending Reviews.decision:"approve"or"reject".remark: Optional for approvals, required for rejections.
Example response (approved transfer):
IMPORTANT
If you fail to capture the transaction ID (tid) due to a connection issue, verify the transaction status via List Transactions - transfer, using the reference_id you supplied when initiating the transfer.
{
"success": true,
"message": "OK",
"rdata": {
"tid": "682281461ff5d617d2eae8c0"
}
}Management
Scope: This section applies only to admin users with sweep permissions.
The sweep and rebalance destinations are the Hot Wallet Withdrawal or Cold Wallet multi-signature addresses that have been configured with the appropriate flags in the CoKeeps Administration platform.
Sweep Deposits
Sweep user deposit balances into a designated omnibus / Withdrawal / Holding / multi-signature account.
// Returns a Promise
CKSDK.management.sweep_deposits({
chain_id: "litecoin",
to: "QXgcRFDWAXbj7QQ7VdZC9vC6U1LUqy5yU9",
uids: [ "c80df78a-95ef-4717-8c0d-081fcb352994" ], // Optional
baseChain: false, // Optional
minimumThreshold: false, // Optional
target_chain_id: false // Optional
});to: One of the configured sweep destination addresses (e.g. Withdrawal / Holding / omnibus multi-signature).uids(optional): Array of user UUIDs whose deposit addresses you want to sweep.- If omitted, all deposit addresses with a non-zero balance will be swept (typical scenario).
baseChain(optional, boolean): Whentrue, sweeps the network native asset (base gas asset) instead of the token from deposit addresses if the balance exceeds:- The dust threshold, or
- The Gas Station funding minimum deposit.
minimumThreshold(optional, string): Decimal string. When set, any deposit balance equal to or below this value will be ignored.target_chain_id(optional): Used in specialised flows where network native assets were allocated to recover tokens deposited on the wrong network.- When set,
uidsmust be provided.
- When set,
Example response:
IMPORTANT
You can track sweep status via List Transactions - sweep-deposit.
{
"success": true,
"message": "OK",
"rdata": {
"processing": [
{
"address": "QgDYu6CGSgz8cbw6VjmLEvQM6UMHKWqRbd",
"uid": "66b89a8d3f5a710012eb6e2c",
"tid": "66b960f97a6a430012ead003",
"error": false
},
// -- Snip --
]
}
}NOTE
To confirm on-chain inclusion, use Lookup Transaction API and inspect the block information.
Sweep Withdrawal
Sweep the full balance from a Withdrawal account into a Holding account. This differs from Transfer Transaction, which can only send funds to user approved destinations.
// Returns a Promise
CKSDK.management.sweep_withdrawal({
chain_id: "litecoin",
from: "QQ4fnSJPWxBPC4RPH4U8J9ucgFvecqvbBK",
to: "QXgcRFDWAXbj7QQ7VdZC9vC6U1LUqy5yU9",
baseChain: false // Optional
});to: One of the configured Holding addresses.from: The Withdrawal account address to be swept.baseChain(optional, boolean): Whentrue, sweeps the native base asset (gas asset) as well, provided the balance exceeds the dust threshold or Gas Station funding minimum.- If the Withdrawal account is a multi-signature account, base balances held by members are also swept.
Example response:
IMPORTANT
You can track sweep status via List Transactions - sweep-withdrawal.
{
"success": true,
"message": "OK",
"rdata": {
"processing": [
{
"address": "QQ4fnSJPWxBPC4RPH4U8J9ucgFvecqvbBK",
"tid": "66b971484fec6500121738ff",
"error": false
},
// -- Snip --
]
}
}NOTE
To confirm on-chain inclusion, use Lookup Transaction API and inspect the block information.
Sweep Gas Station
Sweep the remaining balance from a Gas Station account into a Holding account.
IMPORTANT
Ensure that another Gas Station is configured and active if there are still accounts that require automatic gas funding.
// Returns a Promise
CKSDK.management.sweep_gas_station({
chain_id: "optimism",
from: "0xb43ddb4c9D42c05Bbcc237BD8d1C74DDD44710aD",
to: "0x54105432f2b0caeb3AD7119696ED5B14c2e1C1D3"
});to: One of the configured Holding addresses.from: The Gas Station account address to sweep from.
Example response:
IMPORTANT
You can track sweep status via List Transactions - sweep-gas-station.
{
"success": true,
"message": "OK",
"rdata": {
"tid": "66d4a1c1ebb3b700115fe55e"
}
}NOTE
To confirm on-chain inclusion, use Lookup Transaction API and inspect the block information.
Sweep Signer Wallet Base
Sweep the funded base asset balances from Signer Wallets that no longer hold any token balances.
// Returns a Promise
CKSDK.management.sweep_signer_wallet_bases({
chain_id: "usdt",
to: "0xF089B217705cf3B9aDFF4757171F72318554820b",
uids: [ "c80df78a-95ef-4717-8c0d-081fcb352994" ], // Optional
});to: One of the configured sweep destination addresses.uids(optional): Array of user UUIDs whose Signer Wallet base balances you want to sweep.- If omitted, all eligible Signer Wallet base balances will be swept (typical scenario).
Example response:
IMPORTANT
You can track sweep status via List Transactions - sweep-signer-wallet-bases.
{
"success": true,
"message": "OK",
"rdata": {
"processing": [
{
"address": "0x49d0A29FAa7F36161740f0A046e0e976A918C8CE",
"tid": "66c5b16d60e4f50012f15d7c",
"error": false
},
// -- Snip --
]
}
}NOTE
To confirm on-chain inclusion, use Lookup Transaction API and inspect the block information.
Re-balance
Re-balance funds between a Holding and Withdrawal account pair, according to a fixed amount or a ratio.
// Returns a Promise
CKSDK.management.rebalance({
chain_id: "solana",
from: "J6pZKwXQhbA7WEKKBc2cY7gFSLyAyJNUkpetsZDFTpjp",
to: "38PBWTJJEqCXHQhtRDs3gmsWY4Vtq87arhmTkm5UcSen",
amount: "70:30", // or "15.663" SOL
execute: false // Default
});from/to: Holding or Withdrawal account addresses configured as rebalancing counterparts.amount(string) Can be represented as:- Fixed decimal amount: e.g.
"15.663"(transfer this amount fromfromtoto), or - Ratio:
"from_percentage:to_percentage", e.g."30:70".
For example, if the combined balance across
fromandtois1,000andamountis"30:70", then after a successful rebalance:fromwill hold300,towill hold700.
- Fixed decimal amount: e.g.
execute(boolean, defaultfalse):- When
false, returns a simulation/summary of the rebalance result and any errors, without sending transactions. - When
true, executes the rebalance on-chain.
- When
IMPORTANT
You can track rebalance status via List Transactions - rebalance.
Example response - Successful rebalance (with execute: true):
{
"tid": "683567ae7f715ba4e699754a",
"from": "0x41AF2F15A41eF5930B7D91957121D9A42b30b7F1",
"to": "0x3E7366Bcf69b5bfE0b9fe70E4052c0e07A11BEB4",
"holdingAddress": "0x3E7366Bcf69b5bfE0b9fe70E4052c0e07A11BEB4",
"withdrawalAddress": "0x41AF2F15A41eF5930B7D91957121D9A42b30b7F1",
"error": ""
}Example response - Failed rebalance or dry-run (execute: false):
{
"direction": { "from": "withdrawal", "to": "holding", "amount": "0.01" },
"info": { "chain_id": "ethereum", "name": "Ethereum", "decimals": 18 },
"holding": {
"balance": "6.61770902",
"address": "0x3E7366Bcf69b5bfE0b9fe70E4052c0e07A11BEB4"
},
"withdrawal": {
"balance": "0.000000165",
"address": "0x82f7D764687bC552507F8083c645a41A2fB7A26E"
},
"error": "Amount exceeds balance." // Or "" if no error
}NOTE
To confirm that a successful rebalance has been included in a block, use Lookup Transaction API and inspect the block information for the returned tid.
MasChain
This scope is intended for teams integrating MasChain with CoKeeps KMS, covering both single-signature and multi-signature workflows. By combining MasChain smart contracts with CoKeeps multi-signature capabilities, you can upgrade any MasChain-deployed contract to infrastructure-grade governance and security.
Before using the MasChain integration:
- Obtain your API Key and API Secret from the MasChain platform.
- Create a dedicated Organisation Wallet Address, which is required for automated multi-signature contract deployments.
Generate Single-Signature Wallet
Create a single-signature wallet on MasChain. This wallet can:
- Interact directly with any supported smart contract; or
- Act as an owner within a multi-signature configuration.
// Returns a Promise
CKSDK.maschain.generate_wallet({
chain_id: "maschain" | "maschaintestnet",
label: "Account 1",
message: "A message to sign for proof of ownership" // Optional
});label:Your system must store user-created labels. Each label deterministically generates a unique address per user.
Using the same label value for different users will not result in the same wallet address.
message(optional):If provided, the wallet attempts to sign this message with its private key (e.g. for proof-of-ownership workflows).
Use this carefully; users may unintentionally sign content they do not fully understand.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"address": "0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2",
"signature": "0x90646636720286dba9cb67c374acd13fb410dba370f73f2e7ca6ed9ef2ba7010722af34addc77b82c62f534df827fb76821322d8f9fbc56c4569a0e420a041f11b",
"pubkey": "0x02316c398e1bdd4b1419b87889be46814ee91577982f45a1366d25cfd1ab942931"
}
}Generate Multi-Signature Account
Create a multi-signature account whose members are single-signature wallet addresses.
// Returns a Promise
CKSDK.maschain.generate_multisig_wallet({
chain_id: "maschain" | "maschaintestnet",
label: "Token Governance Account",
threshold: 3,
owners: ["0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2", "0xE10BCd3B7c70473b111Cd1894930af2df2f96322", "0xdbCcf4e89c56da505513D3cED43D13ECf9A4E293"]
});label:A descriptive name for the multi-signature account.
Unlike single-signature wallets, the label does not determine the account's address.
threshold: The number of required signatures to authorise any multi-signature transaction.owners: Array of single-signature wallet addresses that will become members of the multi-signature account.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"address": "0x7f4262f713d4F944d636c06375fc58038EDCf98e"
}
}Build Data
Encode a smart-contract method and its arguments into a hexadecimal payload.
This payload can then be used in single-signature or multi-signature transactions.
// Returns a Promise
CKSDK.maschain.build_data({
chain_id: "maschain" | "maschaintestnet",
projectSlug: "project-apple-berry",
versionSlug: "99-011",
method: "mint",
values: ["0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2", "5000"],
contractName: "TokenERC20" // Optional
});projectSlug,versionSlug: Identifiers for the smart-contract project and version you uploaded to the MasChain platform.method: The smart-contract method name (e.g."mint").values: An array of arguments for the method. The order must exactly match the ABI input order.contractName(optional): The specific contract within the compiled artifact set. If omitted, the first contract in the artifact collection is used.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"data": "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
}
}Wallet Transact
Execute a smart-contract transaction directly from a single-signature wallet using an encoded data payload.
This function returns a transaction hash that you can later verify using Transaction Lookup.
// Returns a Promise
CKSDK.maschain.wallet_transact({
chain_id: "maschain" | "maschaintestnet",
label: "Account 1",
method: "mint",
to: "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
data: "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
});label: Determines which single-signature wallet (created earlier with the same label) is used to sign and send the transaction.method: Name of the smart-contract method this transaction represents (must align with the encodeddata).to: The target smart-contract address.data: The encoded function payload, typically produced byCKSDK.maschain.build_data.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"hash": "0xaa3c57e189189b9efa6c6346673e46c7992c13c0908692dae9b894e7f61f1f6c"
}
}Create Multi-Signature Unsigned Transaction
Initiate a multi-signature transaction for a smart-contract interaction.
This returns an unsigned, serialised transaction, which will then be distributed for signing by the multi-signature members.
// Returns a Promise
CKSDK.maschain.create_multisig_unsigned_tx({
chain_id: "maschain" | "maschaintestnet",
address: "0x7f4262f713d4F944d636c06375fc58038EDCf98e",
to: "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
data: "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
});address: The multi-signature account address.to: The target smart-contract address that the multi-signature account will interact with.data: Encoded function payload for the intended smart-contract method.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"unsigned_tx": "7b22646f6d61696e223a7b226e616d65223a22436f4b65657073204d756c7469536967222c227..."
}
}Sign multi-signature unsigned transaction
Collect signatures from multi-signature members and relay the transaction once the threshold is met.
// Returns a Promise
CKSDK.maschain.sign_multisig_unsigned_tx({
chain_id: "maschain" | "maschaintestnet",
label: "Account 1",
address: "0x7f4262f713d4F944d636c06375fc58038EDCf98e",
unsigned_tx: "7b22646f6d61696e223a7b226e616d65223a22436f4b65657073204d756c7469536967222c227...",
collected_signed_tx: undefined | ["0x138be985201523dc46e7e40048dc438fca66469cd41088d9f53647d49c4..."]
});label: Determines which single-signature wallet is used to sign this step (the signer must be an owner of the multi-signature account).address: The multi-signature account address.unsigned_tx: The unsigned transaction string produced bycreate_multisig_unsigned_tx.collected_signed_tx:- Omit this for the first signer.
- For subsequent signers, include an array of previously produced
signed_txvalues.- For a 2-of-3 multi-signature:
- Signer 1: omits
collected_signed_tx. - Signer 2: provides
[signed_tx_from_signer_1].
- Signer 1: omits
- For a 3-of-3 multi-signature:
- Third signer includes
[signed_tx_signer_1, signed_tx_signer_2].
- Third signer includes
- For a 2-of-3 multi-signature:
Response types:
1. Without collected_signed_tx (or threshold not yet met): returns a signed transaction.
{
"success": true,
"message": "OK",
"rdata": {
"signed_tx": "0x138be985201523dc46e7e40048dc438fca66469cd41088d9f53647d49c4..."
}
}2. With collected_signed_tx meeting the threshold: relays the transaction and returns its hash.
{
"success": true,
"message": "OK",
"rdata": {
"hash": "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e"
}
}Transaction Lookup
Check whether a MasChain transaction has been confirmed and included in a block.
If blockNumber or blockHash is absent or null, the transaction is still pending.
// Returns a Promise
CKSDK.maschain.transaction_lookup({
chain_id: "maschain" | "maschaintestnet",
hash: "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e"
});Example response:
{
"success": true,
"message": "OK",
"rdata": {
"result": {
"transactionHash": "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e",
"transactionIndex": 0,
"blockHash": "0xcca145a15d5f798908da55ae08d54a6f06e8f4d2e8be856ddf6d83b2332aff20",
"from": "0xe10bcd3b7c70473b111cd1894930af2df2f96322",
"to": "0xe404088831c870202487c18fe2c7d5138569a41d",
"blockNumber": 9419780,
"cumulativeGasUsed": 244118,
"gasUsed": 244118,
"contractAddress": null,
"logs": [
{
"address": "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
"topics": [ "0xddf252ad1be2c..." ],
"data": "0x0000000...",
"blockHash": "0xcca145a15d5f798908da55ae08d54a6f06e8f4d2e8be856ddf6d83b2332aff20",
"blockNumber": 9419780,
"transactionHash": "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e",
"transactionIndex": 0,
"logIndex": 0,
"transactionLogIndex": "0x0",
"removed": false,
"id": "log_51c03ec5"
}
],
"logsBloom": "0x0000000080...",
"status": true,
"effectiveGasPrice": 0,
"type": "0x1"
}
}
}Read Contract
Perform a read-only call against any deployed MasChain smart contract.
// Returns a Promise
CKSDK.maschain.read_contract({
chain_id: "maschain" | "maschaintestnet",
projectSlug: "project-apple-berry",
versionSlug: "99-011",
method: "balanceOf",
values: ["0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2"],
address: "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
from: "0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2",
contractName: "TokenERC20" // Optional
});projectSlug,versionSlug: Refer to the contract project and version uploaded to MasChain.method: Read-only contract method (e.g."balanceOf").values: Array of method arguments, in the same order as defined in the ABI.address: Target contract address on MasChain.from: Caller address used as execution context (e.g. wheremsg.senderis relevant for the view logic).contractName(optional):The specific contract name within the artifact collection.
If omitted, the first contract in the artifact is used.
Example response:
{
"success": true,
"message": "OK",
"rdata": {
"result": "5000"
}
}