Files

5.0 KiB

Link Signer

Each subaccount can have at most one linked signer at a time. A linked signer can perform any execute on behalf of the subaccount it is linked to. Use the Linked Signer query to view your current linked signer.

{% hint style="warning" %} Please note:

  • To enable a linked signer, your subaccount must have a minimum of 5 USDT0 worth in account value. {% endhint %}

Rate limits

  • A max of 50 link signer requests every 7 days per subaccount. (weight=30). Use the Linked Signer Rate Limit query to check a subaccount's linked signer usage and remaining wait time.

{% hint style="info" %} See more general details in API Rate limits. {% endhint %}

Request

{% tabs %} {% tab title="Websocket" %} Connect

WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]

Message

{
  "link_signer": {
    "tx": {
      "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
      "signer": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
      "nonce": "1"
    },
    "signature": "0x"
  }
}

{% endtab %}

{% tab title="REST" %} POST [GATEWAY_REST_ENDPOINT]/execute

Body

{
  "link_signer": {
    "tx": {
      "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
      "signer": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
      "nonce": "1"
    },
    "signature": "0x"
  }
}

{% endtab %} {% endtabs %}

Request Parameters

ParameterTypeRequiredDescription
txobjectYesA link signer transaction object. See Signing section for details on the transaction fields.
tx.senderstringYesHex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.
tx.signerstringYesA bytes32 sent as a hex string; includes the address (first 20 bytes) that'll be used as the sender's signer. the last 12 bytes can be set to anything.
tx.noncestringYesThis is an incrementing nonce, can be obtained using the Nonces query.
signaturestringYesSigned transaction. See Signing section for more details.

Signing

{% hint style="info" %} See more details and examples in our signing page. {% endhint %}

The solidity typed data struct that needs to be signed is:

struct LinkSigner {
    bytes32 sender;
    bytes32 signer;
    uint64 nonce;
}

sender: a bytes32 sent as a hex string; includes the address and the subaccount identifier of the primary subaccount to add a signer to.

signer: a bytes32 sent as a hex string; includes the address (first 20 bytes) that'll be used as the sender's signer.

{% hint style="info" %} Notes:

  • the last 12 bytes of the signer field do not matter and can be set to anything.
  • set signer to the zero address to revoke current signer on the provided sender. {% endhint %}

nonce: the tx_nonce. This is an incrementing nonce, can be obtained using the Nonces query.

{% hint style="warning" %} Note: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: nonce should be an uint64 for Signing but should be sent as a string in the final payload. {% endhint %}

Response

Success

{
  "status": "success",
  "signature": {signature},
  "request_type": "execute_link_signer"
}

Failure

{
  "status": "failure",
  "signature": {signature},
  "error": "{error_msg}",
  "error_code": {error_code},
  "request_type": "execute_link_signer"
}