Skip to content

JavaScript SDK API

Tools

NOTE

If Node.js is the chosen environment, a dedicated Node.js SDK can be made available for utilizing this method.

Arithmetic

This tool performs safe arithmetic operations. Ensure that you provide values as strings rather than integers or floating-point numbers to accurately maintain their values when used as variables.

Use + for addition, - for subtraction, x for multiplication, and / for division.

javascript
const operation = "+"; // Addition
const a = "5.2231";
const b = "6";
const decimal = 4;
const result = CKSDK.tool.arithmetic(operation, a, b, decimal);

NOTE

The result will always be a string.

Decimal to Integer

This tool converts decimals to integers safely. You can optionally output the value in BigInt format by passing an additional variable into the function; otherwise, it will always output the value as a string.

javascript
const value = "5.2231";
const decimal = 4;
const outputBigInt = true;
const result = CKSDK.tool.dec_to_int(value, decimal, outputBigInt);

Integer to Decimal

This tool converts integers to decimals safely.

javascript
const value = "52231";
const decimal = 4;
const result = CKSDK.tool.int_to_dec(value, decimal);

NOTE

The result will always be a string.

Pagination filters

This SDK API provides options for performing pagination queries.

NOTE

If Node.js is the chosen environment, a dedicated Node.js SDK can be made available for utilizing this method.

Options include:

  • users
  • destinations
  • travelRules
  • ledger
  • pool
  • review
  • accounts
  • monitor
  • transactions
    • transfer
    • sweepDeposit
    • sweepWithdrawal
    • sweepGasStation
    • sweepSignerWalletBase
    • gasStation
    • rebalance

Here's an example using the transactions -> transfer filter:

javascript
const params = CKSDK.pagination.filters.transactions.transfer;
console.log(params);

Here's an example output of the above:

json
[
    // -- Snip --
    {
        "key": "tid",
        "type": "string",
        "text": "Tx ID",
        "value": null,
    },
    {
        "key": "uid",
        "type": "string",
        "text": "UID",
        "value": null,
    },
    // -- Snip --
]

Here are the value types:

  • string: Represents a string value.
  • Date: Denotes a Date object. Eg. new Date('now').
  • boolean: Represents either true or false.
  • number: Denotes a numerical value. Eg. !isNaN("5.2").

Actions

NOTE

This scope covers both signer and admin roles. admin cannot approve their own actions and must be approved by other admin.

Set Destination Address

In the transfer procedure, users are required to provide the destination address for their transaction transfer recipient. Typically, this destination address must undergo approval before the transfer can proceed.

javascript
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",
    // For Travel Rule
    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",
    addressSignature: "637b9be6f950135997306976c6dea4d1bc956c17b985194ee7398697949e8b07798eba71eb37becca027ceacd55c1ebc67131a98bf0f30fa8b6ae9c7df42ae0762326431356331376431663263646530343564373331336461616666396437663437613962386364343336373133313661663430633734663330613931643539",
    addressSignatureInput: ""
});

For the "Self Hosted" type, you must define the following variables:

  • addressSignature: This is the signature digest of the message signing of the address value using the private key for proof of address ownership. WalletConnect can be used to sign the address as a message.

  • addressSignatureInput: This is the Public Key for Ripple or Solana SPL-Token only.

NOTE

Only one destination address can be set at a time per chain.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "id": "66c56b3e66a0c500120d9237",
  }
}

Retrieve Deposit Address

If your platform involves accepting coins or tokens as part of your product or service, such as for digital asset trading, you'll need a temporary deposit address for each user to receive incoming funding.

IMPORTANT

The address is unique for each chain and changes with every credential reset!

javascript
// Returns a Promise
CKSDK.action.generate_deposit({
  chain_id: "ethereum",
  index: 0 // Optional
});

For admin with the permission to sweep, deposits can be transferred into a multi-signature transaction assigned to receive them.

Create a deposit address by specifying the index parameter integer value, which is optional and defaults to zero (0) if not provided. This allows you to generate multiple deposit addresses for your users, with no limit on the number of addresses that can be created.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "address": "0x391EF99987f60CE0cf3382FE00295B0c1e8DE6b5",
      "index": 0
  }
}

Retrieve Signer Wallet Address

javascript
// 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 a record of all user-created labels. Each label deterministically generates a user-unique address. The same label value used by different users will not produce the same single-signature account.

If a message value is provided, the wallet will attempt to sign the message using its private key. Exercise caution when exposing this feature to your users, as they may inadvertently sign a transaction that was not intended.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "address": "9oZ3kPXx1wmnBuDMqiiyKBFt1KKMVT1gPE92N243dfMj",
      "signature": "4923391799a54860d7408aa8b889e126a3fb1af51ba17474d627af35c53f183bf8c7b4e2ea528cc2702afa6646f131eeaa525b5a2194a50002097e2aa1f53903"
  }
}

Transfer Transaction

NOTE

For Signer Wallet, this method allows for transfer moderation by requiring administrator review before blockchain relay. Pending items are available in List Pending Reviews. Please inform us if you'd like to enable this feature.

javascript
// 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
});

The from field represents the address of the user's Signer Wallet or a Withdrawal account.

The to field value must match the destinations entry in the Read endpoint.

The amount is a string of decimals and it should not exceed the limits specified by your Read endpoint.

The memo field is limited to 256 characters.

The reference_id is your system-generated reference ID for this transaction.

The estimateFee is a boolean flag that, when set, returns the estimated transaction cost without executing the transaction.

Example response:

  • No Pending Review

IMPORTANT

If you failed to retrieve the transaction ID (tid) due to a loss of connection, please verify the status of the transaction against List Transactions - transfer with reference_id.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "tid": "66c56b0d66a0c500120d9234"
  }
}
  • Pending Review

NOTE

If the Pending Review feature is enabled, transfer requests are queued for administrator approval. In this mode, the endpoint returns a rid (Review ID) instead of a tid (Transaction ID).

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "rid": "66c56b0d66a0c500120d9234"
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

If the estimateFee flag is used, you'll get the following result. The value is in the native currency's lowest denomination integer format.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "estimatedFee": "34885913140"
  }
}

Smart Contract Transaction

NOTE

This method doesn't immediately execute the transaction and may undergo stages of approval depending on your setup.

IMPORTANT

  1. For ERC-20 or SPL-Token Token transfer, please use the Transfer Transaction API mentioned previously.
  2. Only smart contract deployed or imported within the CoKeeps platform can be queried.
javascript
// 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
});

The from field represents the address of the user's Signer Wallet or Deposit.

The address field represents the address of the smart contract to interact with. This smart contract must already be approved by the organisation via the Client Administration platform.

The method and methodArgs can be obtained from the Back-End REST API Smart Contract Lookup Interface section.

The reference_id is your system-generated reference ID for this transaction.

The estimateFee is a boolean flag that, when set, returns the estimated transaction cost without executing the transaction.

The target_chain_id is utilized to recover transfers made to a token deposit address on the wrong network.

Example response:

IMPORTANT

If you failed to retrieve the transaction ID (tid) due to a loss of connection, please verify the status of the transaction against List Transactions - interact with reference_id.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "tid": "66d48fe2ebb3b700115fe55b"
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

If the estimateFee flag is used, you'll get the following result. The value is in the native currency's lowest denomination integer format.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "estimatedFee": "8232846"
  }
}

Omnibus Withdrawal

NOTE

This method doesn't immediately execute the transaction and may undergo stages of approval depending on your setup.

javascript
// Returns a Promise
CKSDK.action.omnibus_withdraw({
  chain_id: "solana",
  amount: "1000",
  memo: "Test withdraw from Omnibus account",
  reference_id: "TICKET-125"
});

The maximum amount value should be the balance of the user's Dynamic Ledger or any value defined by your back-end Read endpoint.

The memo field is limited to 256 characters.

The reference_id is your system-generated reference ID for this transaction.

The recipient of a withdrawal request would be the address value defined in the Set Destination Address action mentioned previously.

Example response:

IMPORTANT

If you failed to retrieve the withdrawal ID (id) due to a loss of connection, please verify the status of the request against List Transactions.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "id": "66c56d6666a0c500120d923b"
  }
}

Decisions

NOTE

This scope is exclusive to the admin role. admin cannot approve their own actions and must be approved by other admin.

Approve / Reject Destination Address

NOTE

The decision made for the destination address will automatically apply to any attached travel rule information.

javascript
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",
});

The _id represents the Destination ID obtained from the Back-End REST API Information List Destinations.

The remark field is required for the reject decision.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "id": "66c5338caf2057001226d679"
  }
}

Approve / Reject Travel Rule

javascript
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",
});

The _id represents the Travel Rule ID obtained from the Back-End REST API Information List Travel Rules.

The remark field is required for the reject decision.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "id": "66b974505e39400012dabd34"
  }
}

Approve / Reject Transaction Request

javascript
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",
});

The _id represents the Dynamic Transaction Pool ID obtained from the Back-End REST API Dynamic Transaction Pool List Transactions.

The value for the from field is specifically applicable to the Omnibus Withdrawal procedure, where it can be retrieved from the Back-End REST API Dynamic Transaction Pool Retrieve Integrated Accounts.

The remark field is required for the reject decision.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "id": "66c56d6666a0c500120d923b"
  }
}

Approve / Reject Pending Reviews

javascript
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",
});

The _id represents the Review ID obtained from the Back-End REST API Information List Pending Reviews.

The remark field is required for the reject decision.

Example response, tid represents the approved transaction ID:

IMPORTANT

If you failed to retrieve the transaction ID (tid) due to a loss of connection, please verify the status of the transaction against List Transactions - transfer with reference_id.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "tid": "682281461ff5d617d2eae8c0"
  }
}

Management

NOTE

This section pertains exclusively to admin with sweep permissions.

The destinations for sweeping or rebalancing actions are the designated hot wallet or cold wallet multi-signature addresses that have specific flag options set within the CoKeeps Administration Platform.

Sweep Deposits

javascript
// 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
});

The to field is the one or more sweep destination addresses that have been configured.

The uids field is an array of specific UUIDs representing the collective deposits you wish to sweep. If not provided, the operation will sweep everything from deposit addresses with a balance, which is the common scenario.

The baseChain field is a boolean flag that, when set, will sweep the native currency if the balance exceeds the dust threshold or the Gas Station funding minimum deposit.

The minimumThreshold field is a decimal number in string format that, when set, will ignore any deposit balances equal to or below the threshold value.

The target_chain_id is utilized to sweep the network coin balance that was utilized to recover tokens deposited to an incorrect network. Entry in uids must be provided.

Example response:

IMPORTANT

You can verify the status of the sweep against List Transactions - sweep-deposit.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "processing": [
          // -- Snip --
          {
            "address": "QgDYu6CGSgz8cbw6VjmLEvQM6UMHKWqRbd",
            "uid": "66b89a8d3f5a710012eb6e2c",
            "tid": "66b960f97a6a430012ead003",
            "error": false
          },
          // -- Snip --
      ]
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

Sweep Withdrawal

This method is exclusively used to transfer the entire balance from a Withdrawal account to a Holding account, unlike the Transfer Transaction, which can only send funds to approved destinations. Please note that a dust amount may still remain in the balance.

javascript
// Returns a Promise
CKSDK.management.sweep_withdrawal({
  chain_id: "litecoin",
  from: "QQ4fnSJPWxBPC4RPH4U8J9ucgFvecqvbBK",
  to: "QXgcRFDWAXbj7QQ7VdZC9vC6U1LUqy5yU9",
  baseChain: false // Optional
});

The to field is the one or more Holding addresses that have been configured.

The from field represents the Withdrawal account address to sweep from.

The baseChain field is a boolean flag that, when set, will sweep the native currency if the balance exceeds the dust threshold or the Gas Station funding minimum deposit. If the Withdrawal account is a Multi-Signature account, it will also sweep the member balance.

Example response:

IMPORTANT

You can verify the status of the sweep against List Transactions - sweep-withdrawal.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "processing": [
          // -- Snip --
          {
            "address": "QQ4fnSJPWxBPC4RPH4U8J9ucgFvecqvbBK",
            "tid": "66b971484fec6500121738ff",
            "error": false
          },
          // -- Snip --
      ]
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

Sweep Gas Station

This method allows you to clear the balance of a Gas Station account and transfer it to a Holding account. Ensure that another Gas Station is active if there are addresses that still need automatic funding for gas payments.

javascript
// Returns a Promise
CKSDK.management.sweep_gas_station({
  chain_id: "optimism",
  from: "0xb43ddb4c9D42c05Bbcc237BD8d1C74DDD44710aD",
  to: "0x54105432f2b0caeb3AD7119696ED5B14c2e1C1D3"
});

The to field is the one or more Holding addresses that have been configured.

The from field represents the Gas Station account address to sweep from.

Example response:

IMPORTANT

You can verify the status of the sweep against List Transactions - sweep-gas-station.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "tid": "66d4a1c1ebb3b700115fe55e"
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

Sweep Signer Wallet Base

This method allows you to clear the funded base balance of Signer Wallets that do not have any token balance.

javascript
// Returns a Promise
CKSDK.management.sweep_signer_wallet_bases({
  chain_id: "usdt",
  to: "0xF089B217705cf3B9aDFF4757171F72318554820b",
  uids: [ "c80df78a-95ef-4717-8c0d-081fcb352994" ], // Optional
});

The to field is the one or more sweep destination addresses that have been configured.

The uids field is an array of specific UUIDs representing the collective signer wallets you wish to sweep. If not provided, the operation will sweep everything from signer wallet addresses base balances, which is the common scenario.

Example response:

IMPORTANT

You can verify the status of the sweep against List Transactions - sweep-signer-wallet-bases.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
      "processing": [
          // -- Snip --
          {
            "address": "0x49d0A29FAa7F36161740f0A046e0e976A918C8CE",
            "tid": "66c5b16d60e4f50012f15d7c",
            "error": false
          },
          // -- Snip --
      ]
  }
}

NOTE

To verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

Re-balance

javascript
// Returns a Promise
CKSDK.management.rebalance({
  chain_id: "solana",
  from: "J6pZKwXQhbA7WEKKBc2cY7gFSLyAyJNUkpetsZDFTpjp",
  to: "38PBWTJJEqCXHQhtRDs3gmsWY4Vtq87arhmTkm5UcSen",
  amount: "70:30", // or "15.663" SOL
  execute: false // Default
});

The from and to fields represent either a Withdrawal or Holding account address configured for re-balancing between these accounts.

The amount field must be a string that can be represented either as a fixed decimal amount or as a ratio. A ratio value is represented as from_percentage:to_percentage. For example, if the combined balance of the "from" and "to" accounts is 1,000 and the ratio is "30:70", the rebalance procedure will result in the "from" account having a new balance of 300 and the "to" account having a balance of 700.

The execute field is a boolean flag. By default, it returns the summary of the rebalance. If set to true, it will execute the rebalance procedure.

IMPORTANT

You can verify the status of the rebalance against List Transactions - rebalance.

Example Response: Successful Rebalance Response

json
{
  "tid": "683567ae7f715ba4e699754a",
  "from": "0x41AF2F15A41eF5930B7D91957121D9A42b30b7F1",
  "to": "0x3E7366Bcf69b5bfE0b9fe70E4052c0e07A11BEB4",
  "holdingAddress": "0x3E7366Bcf69b5bfE0b9fe70E4052c0e07A11BEB4",
  "withdrawalAddress": "0x41AF2F15A41eF5930B7D91957121D9A42b30b7F1",
  "error": "" 
}

Example: Failed Rebalance or when execute is set to false

json
{
  "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 verify if the transaction has been confirmed and included in a block, please utilize the Lookup Transaction API and check the block number.

MasChain

This scope is intended for teams integrating MasChain with CoKeeps KMS. It covers single-signature and multi-signature workflows. CoKeeps multi-signature allows you to upgrade any smart contract deployed on MasChain, significantly improving infrastructure-grade governance and security.

Before using the MasChain integration, obtain your API Key and API Secret from the MasChain platform. You must also create a dedicated Organization Wallet Address, which is required for automated multi-signature contract deployments.

Generate Single-Signature Wallet

Use this to create a single-signature wallet. It can operate independently for any smart-contract interaction or serve as a signer within a multi-signature setup.

javascript
// Returns a Promise
CKSDK.maschain.generate_wallet({
  chain_id: "maschain" | "maschaintestnet",
  label: "Account 1",
  message: "A message to sign for proof of ownership" // Optional
});

Your system must maintain a record of all user-created labels. Each label deterministically generates a user-unique address. The same label value used by different users will not produce the same single-signature account.

If a message value is provided, the wallet will attempt to sign the message using its private key. Exercise caution when exposing this feature to your users, as they may inadvertently sign a transaction that was not intended.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "address": "0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2",
     "signature": "0x90646636720286dba9cb67c374acd13fb410dba370f73f2e7ca6ed9ef2ba7010722af34addc77b82c62f534df827fb76821322d8f9fbc56c4569a0e420a041f11b",
     "pubkey": "0x02316c398e1bdd4b1419b87889be46814ee91577982f45a1366d25cfd1ab942931"
  }
}

Generate Multi-Signature Account

Creates a multi-signature account with any combination of signers. The account’s members are single-signature wallets.

Returns the address of the newly created multi-signature account.

javascript
// Returns a Promise
CKSDK.maschain.generate_multisig_wallet({
  chain_id: "maschain" | "maschaintestnet",
  label: "Token Governance Account",
  threshold: 3,
  owners: ["0x6A2318e8Ee1C39C74c1b9207553de5dA777c54D2", "0xE10BCd3B7c70473b111Cd1894930af2df2f96322", "0xdbCcf4e89c56da505513D3cED43D13ECf9A4E293"]
});

The label is the name of the multi-signature account and, unlike a single-signature wallet, it does not determine the account address.

The threshold is the number of signatures required to authorize any transaction.

The owners field is an array of single-signature wallet addresses that will be the members of the multi-signature account.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "address": "0x7f4262f713d4F944d636c06375fc58038EDCf98e"
  }
}

Build Data

This feature encodes a function call and its arguments into a hexadecimal payload, which can later be executed as a single-signature or multi-signature transaction.

javascript
// 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 and versionSlug are derived from the smart-contract project and version you uploaded to the MasChain platform.

The values field must be an array, and its elements must match the order of the smart-contract ABI inputs.

If contractName is omitted, the first contract in the artifact collection is used by default.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "data": "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
  }
}

Wallet Transact

Executes a transaction from the single-signature wallet using the encoded function data.

This function returns a transaction hash. Use it with the transaction lookup to verify whether the transaction has been confirmed and included in a block.

javascript
// Returns a Promise
CKSDK.maschain.wallet_transact({
  chain_id: "maschain" | "maschaintestnet",
  label: "Account 1",
  method: "mint",
  to: "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
  data: "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
});

The label determines which wallet address is used to execute the transaction.

The method must exactly match the method name used to generate the encoded function data.

The to specifies the target smart-contract address the wallet will interact with.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "hash": "0xaa3c57e189189b9efa6c6346673e46c7992c13c0908692dae9b894e7f61f1f6c"
  }
}

Create Multi-Signature Unsigned Transaction

Initiates a multi-signature transaction for a smart-contract interaction.

Returns an unsigned, serialized transaction that will be used to collect member signatures until the required threshold is met.

javascript
// Returns a Promise
CKSDK.maschain.create_multisig_unsigned_tx({
  chain_id: "maschain" | "maschaintestnet",
  address: "0x7f4262f713d4F944d636c06375fc58038EDCf98e",
  to: "0x31bd9266A0740e34093128ba36B4c7B0543E4A78",
  data: "0x40c10f190000000000000000000000006a2318e8ee1c39c74c1b9207553de5da777c54d2..."
});

The address is the multi-signature account address.

The data field contains the encoded function payload for the smart-contract method you intend to call.

The to specifies the target smart-contract address the multi-signature account will interact with.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "unsigned_tx": "7b22646f6d61696e223a7b226e616d65223a22436f4b65657073204d756c7469536967222c227..."
  }
}

Sign multi-signature unsigned transaction

javascript
// 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..."]
});

The label determines which user's single-signature wallet address is used to sign the transaction.

The address is the multi-signature account address.

unsigned_tx is the unsigned transaction payload produced during initiation and intended for signing by the participating signers.

collected_signed_tx is required only for the final signer who satisfies the threshold. For a 2-of-3 multi-signature account, the first signer omits collected_signed_tx, while the second signer includes the first signer’s signed_tx as the collected_signed_tx array value. For a 3-of-3 account, the third signer includes the first and second signers’ signed_tx values in collected_signed_tx.

Example response:

There are two response types. If collected_signed_tx is omitted, the function returns a signed, serialized transaction. If it is provided and meets the signature threshold, the transaction is relayed and the function returns a transaction hash.

Without collected_signed_tx provided - a signed transaction.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "signed_tx": "0x138be985201523dc46e7e40048dc438fca66469cd41088d9f53647d49c4..."
  }
}

With collected_signed_tx provided - relayed transaction.

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "hash": "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e"
  }
}

Transaction Lookup

Use this to verify whether a transaction has been confirmed and included in a block. If blockNumber, blockHash is absent or null is returned, the transaction is still pending.

javascript
// Returns a Promise
CKSDK.maschain.transaction_lookup({
  chain_id: "maschain" | "maschaintestnet",
  hash: "0xb8e01ea14b24dbef4bedc56b2f31bea556798bf6276835497218ca608f23ab3e"
});

Example response:

json
{
  "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

Performs a read operation on any deployed smart contract.

javascript
// 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 and versionSlug are derived from the smart-contract project and version you uploaded to the MasChain platform.

The method specifies the contract’s read function.

The values field must be an array, and its elements must match the order of the smart-contract ABI inputs.

address is the target contract address.

from is the caller address used as context (e.g., for view logic that depends on msg.sender)

If contractName is omitted, the first contract in the artifact collection is used by default.

Example response:

json
{
  "success": true,
  "message": "OK",
  "rdata": {
     "result": "5000"
  }
}