Send Multiple Signing Transaction

This page introduces how to send a transaction that requires multiple signatures with Wallet API.

Before Getting Started

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item

Description

Note

chain-id

8217 or 1001

Cypress(Klaytn mainnet) or Baobab(Klaytn testnet

access-key-id

Auth ID

accessKeyId obtained from KAS Console - Security - Credential

secret-access-key

Auth Password

secretAccessKey obtained from KAS Console - Security - Credential

krn

(optional) ID of Account Pool

Unnecessary when using Default Account Pool

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a transaction from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel. DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.

Multiple Signing

The term “multisig” means multiple signatures. Klaytn needs transactions to be signed before sending them. In some cases, a single transaction must be signed by several Klaytn accounts as the account used to send the transaction is a multisig with Multiple Signing Key.

For more details on transactions and signing transactions, refer to the followings. For changing the account key into a multisig key, refer to the followings.

Send Multiple Signing Transaction

You can use a multisig account (the account that owns Multiple Signing Key) to send a transaction that has been signed by multiple Klaytn accounts. Follow the instructions below for sending a multisig KLAY transmission transaction.

To send KLAY, the user must send the transaction using KAS to Klaytn Node and pay the transaction fee for this. To call the API, he/she must first create an Account Pool and account, and then select an account to use. In this example, the deploying account must directly pay the transaction fee for sending KLAY.

As an example of sending a transaction with multiple signing, the following steps show how a sending KLAY transaction receives multiple signatures to be sent.

Once the pending transaction is fully signed as required, it is automatically sent to Klaytn.

Get List of Pending Transactions

Search for the list of pending transactions from the current account.

The transaction status will be set to “Pending” if the current account is a multisig account that has not obtained enough signatures for sending a transaction (=sum of the weights of keys used for signing did not exceed the threshold). It will remain pending until it gets the required number of signatures if the signatures are not enough for sending a transaction, although the transaction is sent by a multisig account.

To call the API, he/she must first create an Account Pool and account, and then select an account to use.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

API Request

Call the API for loading pending transactions among those entered Klaytn EOAs. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

Query Parameter

You can receive API response values with Cursor-based Pagination. The search range can also be set by second.

Parameter

Description

Example

Required or Not

size

the number of items in the API response (min=1, max=1000, default=100)

size=100

False

cursor

the cursor required to get the next batch of response items

cursor=J9Ag...VM6z

False

to-timestamp

Search Range: The last timestamp (sec)

to-timestamp=15921809920

False

from-timestamp

Search Range: The first timestamp (sec)

from-timestamp=1592360291

False

curl --location --request GET "https://wallet-api.klaytnapi.com/v2/multisig/account/0xc6C9356887b7F7887918Bf577417E5D8De253295/tx" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \

API Response

Here is the response of the pending transaction list search API.

{
  "cursor": "",
  "items": [
    {
      "address": "0xc6C9356887b7F7887918Bf577417E5D8De253295",
      "chainId": 1001,
      "createdAt": 1599144020,
      "multiSigKeys": [
        {
          "address": "0xc6C9356887b7F7887918Bf577417E5D8De253295",
          "weight": 3
        },
        {
          "address": "0x0b7caaf70e7A0a5399041c64711E535CE8B3cf7d",
          "weight": 1
        }
      ],
      "status": 2,
      "threshold": 4,
      "transactionId": "0x65111d4fba621a1bfa3bd97c219b3e0454471cf3c07827396f1202946df51ee2",
      "txData": {
        "from": "0xc6c9356887b7f7887918bf577417e5d8de253295",
        "gasLimit": 1000000,
        "gasPrice": "0x5d21dba00",
        "input": "0x6d656d6f",
        "to": "0x2f87ba64de5526f7880f21481effbf950f70005c",
        "typeInt": 16,
        "value": "0x1001"
      },
      "type": "TX",
      "updatedAt": 1599144020
    },
    {
      "address": "0xc6C9356887b7F7887918Bf577417E5D8De253295",
      "chainId": 1001,
      "createdAt": 1599144013,
      "multiSigKeys": [
        {
          "address": "0xc6C9356887b7F7887918Bf577417E5D8De253295",
          "weight": 3
        },
        {
          "address": "0x0b7caaf70e7A0a5399041c64711E535CE8B3cf7d",
          "weight": 1
        }
      ],
      "status": 2,
      "threshold": 4,
      "transactionId": "0x36f9c5794fc141d3625e89a1164e6105fa973e8214d23bc6a210d2afe9dba6dd",
      "txData": {
        "from": "0xc6c9356887b7f7887918bf577417e5d8de253295",
        "gasLimit": 1000000,
        "gasPrice": "0x5d21dba00",
        "input": "0x6d656d6f",
        "to": "0x2f87ba64de5526f7880f21481effbf950f70005c",
        "typeInt": 16,
        "value": "0x100"
      },
      "type": "TX",
      "updatedAt": 1599144013
    }
  ]
}

“typeInt” variable is a value for identifying the transaction type. For details about the types of transactions, please visit here.

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Sign Pending Transaction

Sign the pending transactions by calling Sign Transaction API. The transaction status will be set to “Pending” if the current account is a multisig account that has not obtained enough signatures for sending a transaction (=sum of the weights of keys used for signing did not exceed the threshold).

To call the API, he/she must first create an Account Pool and account, and then select an account to use.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

API Request

Call the pending transaction signature API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/multisig/account/0x68Da92c0557A62C292598A3156B770df6e07BD83/tx/0x5d7beaf43d63d27bf8ddd11ac32ee3c853abfe869988526f92431a63fe3dcb1d/sign" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \

API Response

Here is the response of the pending transaction signature API.

// If some signatures are missing when the sum of the weights must be four (4) (=threshold) or higher: If a signature with a weight of one (1) is obtained 
{
  "reminders": [
    "0xf24e881d3cFF241859203DB09a28421267B7F6E6"
  ],
  "signedWeight": 1,
  "status": "Signed",
  "threshold": 4,
  "transactionID": "0xfa275dba88d197a85504ef70e0dd2640acc708817e9eb3933d7850acfb048649",
  "weight": 1
}

// If all signatures are obtained for sending the transaction when the sum of the weights must be four (4) (=threshold) or higher: If a signature with a weight of one (1) and another signature with a weight of three (3) are obtained
{
  "signedWeight": 4,
  "status": "Submitted",
  "threshold": 4,
  "transactionHash": "0x81f2ff422eae9b40d65b7a6f1e3c5ca598f83d1473ccc87e53d51b875fe75c82",
  "transactionID": "0xfa275dba88d197a85504ef70e0dd2640acc708817e9eb3933d7850acfb048649",
  "weight": 3
}
  • reminders: Account addresses of owners of unsigned keys

  • signedWeight: The cumulative sum of weights of signed keys for a specific transaction, which must exceed the “threshold” to send the transaction

  • weight: The weight of signed key

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Sign Pending Transaction - Use Separate Signatures

Sign pending transactions. Append a signature to a pending transaction in this section.

A transaction can be signed using the signature value if there is a Klaytn account created outside KAS that has a signature value. However, the transaction status will be set to “Pending” if the current account is a multisig account that has not obtained enough signatures for sending a transaction (=sum of weights of keys used for signing did not exceed the threshold).

To call the API, he/she must first create an Account Pool and account, and then select an account to use.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

API Request

Call the pending transaction signature API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request POST "https://wallet-api.klaytnapi.com/v2/multisig/tx/0x5d7beaf43d63d27bf8ddd11ac32ee3c853abfe869988526f92431a63fe3dcb1d/sign" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "signatures": [
    {
      "R": "0xaa2ae446f5dd35df839e8ec2005aede91f0b3ea0f1e6889f4294d4760529bfaf",
      "S": "0x7b3efab682bcc86f7050819e12a2b5ea916871d684b9e1c8ca8f49869df41896",
      "V": "0x7f5"
    }
  ]
}"
  • signatures: A prepared signature value of ECDSA signature information (R, S) and public key restoration information (V).

API Response

Here is the response of the pending transaction signature API.

// If some of signatures are obtained when multisig is required: If a signature with a weight of three (3) is obtained only when the threshold is four (4) 
{
  "reminders": [
    "0xA9183eD590ebEDf06D415ae684E3f18d06789f8d"
  ],
  "signedWeight": 3,
  "status": "Signed",
  "threshold": 4,
  "transactionId": "0xa0cabe28c75aa6babbf7e85b5033641c46d0f2e7b714e47103716695d454a45a",
  "weight": 3
}

// If all signatures are obtained as required when multisig is required for sending a transaction: If a signature with a weight of one (1) is obtained only when the threshold is four (4)
{
  "signedWeight": 4,
  "status": "Submitted",
  "threshold": 4,
  "transactionHash": "0xf1ced3855f3cd1d5220f2991ec4ba845ec747a0c01028c2d63de3662ddad2083",
  "transactionId": "0xae20ed8ce084d372fb804ea6f6073ba2f485a64bac086199efb83d665d0b31f2",
  "weight": 1
}
  • reminders: Account addresses of owners of unsigned keys

  • signedWeight: Cumulative sum of weights of signed keys for this transaction, which must exceed threshold to send the transaction

  • weight: Weight of signed key

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Last updated