Build
Skip to content

Action payloads

Each write operation in Sequence Embedded Wallet uses a payload. Payloads are JSON objects. They hold all data about the intent of the action and the user's signature.

The Embedded Wallet SDK generates Payloads. To complete the action, send them to the Embedded Wallet API.

The Embedded Wallet API key authenticates all calls to the Embedded Wallet API. This includes calls to the /sendPayload endpoint. The Embedded Wallet API key is a secret. Keep it safe and never share it or store it in a client-side application. :::

Payload structure

You don't need to manually change the payload contents to integrate Embedded Wallet. But they have strict definitions. Use them if you need to.

The payload structure is as follows:

NameTypeDescriptionOptional
versionstringThe version of the SDK that generated the payloadNo
* packetobjectContents, defined by each payload typeNo
signaturessignature[]Payload signatures by existing sessionsYes
packet.codestringIdentifier of the payload typeNo
packet.issuednumberTimestamp of when the payload was issued, in secondsNo
packet.expiresnumberTimestamp of when the payload will expire, in secondsNo

* packet must be organized such that its fields (in JSON structure) appear alphabetically by name.

The wallet is optional when openning a new session

signature type

NameTypeDescriptionOptional
sessionstringIdentifier of the signing sessionNo
* signaturestringSignature of the session for the given payloadNo

* signature should be an EIP-191 signature. See https://eips.ethereum.org/EIPS/eip-191

{
  "version": "1.0.0",
  "packet": {
    "code": "signMessage",
    "expires": 1600086400,
    "issued": 1600000000,
    "message": "Join game: #284892",
    "network": "137",
    "wallet": "0xBc5F07A5852fdF3DBd57A76835109220D0ADd8E8"
  },
  "signatures": [{
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696",
    "signature": "0x4b0fc0c7d42566958d60f92115ab95167c837c891e2f4fa62a75bfed30d86af7291051fe5c88985269286548a42bed5b70bb16588e48998206a2e7a547f527d101"
  }]
}

Open session payload

Opening a new client-side session on the Embedded Wallet SDK generates this payload. It holds the "proof" that authenticates the user and the session data to link to it.

Either idToken, email or a valid signature MUST be present. If email is given, the Embedded Wallet will email the user on their first transaction with this session. The email asks them to confirm it.

The wallet parameter is optional ONLY for this payload. If given, it ensures that the opened session matches the requested wallet.

NameTypeDescriptionOptional
codestringThe "code" of the payload (openSession).No
sessionstringThe unique identifier for the sessionNo
proofobjectContains authentication details like JWT and emailNo
proof.idTokenstringOAuth2 id tokenYes
proof.emailstringUser's email addressYes

Notice that either idToken, email or a valid signature MUST be present. If email is provided, the Embedded Wallet will send an email on the user's first transaction with this session, asking them to confirm it.

{
  "version": "1.0.0",
  "packet": {
    "code": "openSession",
    "expires": 1600086400,
    "issued": 1600000000,
    "proof": {
      "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbXktZG9tYWluLmF1dGgwLmNvbSIsInN1YiI6ImF1dGgwfDEyMzQ1NiIsImF1ZCI6IjEyMzRhYmNkZWYiLCJleHAiOjEzMTEyODE5NzAsImlhdCI6MTMxMTI4MDk3MCwibmFtZSI6IkphbmUgRG9lIiwiZ2l2ZW5fbmFtZSI6IkphbmUiLCJmYW1pbHlfbmFtZSI6IkRvZSJ9.bql-jxlG9B_bielkqOnjTY9Di9FillFb6IMQINXoYsw",
      "email": "[email protected]"
    },
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696"
  }
}

Sign message payload

This payload is generated when signMessage is called on the SDK.

NameTypeDescriptionOptional
codestringThe "code" of the payload (signMessage).No
walletstringAddress of the wallet.No
networkstringNetwork on which to send the transactions.No
messagestringMessage to be signed.No
{
  "version": "1.0.0",
  "packet": {
    "code": "signMessage",
    "expires": 1600086400,
    "issued": 1600000000,
    "message": "Join game: #284892"
    "network": "1",
    "wallet": "0xBc5F07A5852fdF3DBd57A76835109220D0ADd8E8",
  },
  "signatures": [{
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696",
    "signature": "0x4f9555c73908b6a5b61e0a744cb4e00fce7b20743d5799e4cb1774081bc6b2ec192c740e50f1adec84605636e09c9cdf4d2f6629f9ce64d8d0f3ae10305ef90400"
  }]
}

Send transaction payload

This payload is generated when sendTransaction is called on the SDK.

NameTypeDescriptionOptional
codestringThe "code" of the payload (sendTransaction).No
identifierstringUnique identifier for the transactionNo
walletstringAddress of the wallet.No
networkstringNetwork on which to send the transactions.No
transactions(transaction | erc20send | erc721send | erc1155send | delayedEncode)[]Array of transaction objects.No

Raw transaction

NameTypeDescriptionOptional
typestringTransaction type, should be "transaction"No
tostringThe recipient Ethereum addressNo
valuestringThe value to be transferredYes
datastringAdditional data for the transactionYes

Notice that transactions with to === wallet are strictly forbidden, and will get rejected.

sendERC20

NameTypeDescriptionOptional
typestringTransaction type, should be "erc20send"No
tokenstringThe ERC20 token contract addressNo
tostringThe recipient Ethereum addressNo
valuestringAmount of tokens to sendNo

sendERC721

NameTypeDescriptionOptional
typestringTransaction type, should be "erc721send"No
tokenstringThe ERC721 token contract addressNo
tostringThe recipient Ethereum addressNo
idstringToken ID to sendNo
safeboolWhether to use the safeTransferFrom functionYes
datastringAdditional data for the transactionYes

Notice that data can only be used if safe === true.

sendERC1155

NameTypeDescriptionOptional
typestringTransaction type, should be "erc1155send"No
tokenstringThe ERC1155 token contract addressNo
tostringThe recipient Ethereum addressNo
valsobject[]Array of objects with id and amountNo
vals[].idstringThe ID of the tokenNo
vals[].amountstringAmount of tokens with this ID to sendNo
datastringAdditional data for the transactionYes

delayedEncode

Delayed encode transactions have their payload data not encoded on the client, it instead is left to be encoded by the Embedded Wallet API. This reduces the burden on the client, and makes it easier to integrate in environments with limited libraries.

TypeFieldData TypeDescription
DelayedEncodeDataabistringThe ABI (Application Binary Interface) for the contract.
funcstringThe function to call within the smart contract.
args(string | DelayedEncodeData)[] | { [key: string]: (string | DelayedEncodeData) }The arguments to pass to the function. Can be an array or an object.
DelayedEncodeSubpackettype'delayedEncode'The type of the subpacket, in this case, it's 'delayedEncode'.
tostringThe address to which the transaction is sent.
valuestringThe value being sent in the transaction, usually in Ether for Ethereum.
dataDelayedEncodeDataThe data payload, containing the ABI, function to call, and arguments.

Hope this helps!

{
  "version": "1.0.0",
  "packet": {
    "code": "sendTransaction",
    "expires": 1600086400,
    "identifier": "tx-id1-1600000000",
    "issued": 1600000000,
    "network": "137",
    "transactions": [
      {
        "data": "0x3251ba32",
        "to": "0x479F6a5b0C1728947318714963a583C56A78366A",
        "type": "transaction",
        "value": "39381"
      },
      {
        "to": "0x7b1Bd3474D789e18e2E329E2c53F819B6E687b4A",
        "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "type": "erc20send",
        "value": "1000"
      },
      {
        "data": "0x112233",
        "id": "7",
        "safe": true,
        "to": "0x17fFA2d95b58228e1ECb0C6Ac25A6EfD20BA08E4",
        "token": "0xF87E31492Faf9A91B02Ee0dEAAd50d51d56D5d4d",
        "type": "erc721send"
      },
      {
        "data": "0x223344",
        "to": "0x91E8aC543C5fEDf9F3Ef8b9dA1500dB84305681F",
        "token": "0x631998e91476da5b870d741192fc5cbc55f5a52e",
        "type": "erc1155send",
        "vals": [{
          "amount": "5",
          "id": "2"
        }, {
          "amount": "1",
          "id": "500"
        }]
      },
			{
				"data": {
					"abi": "[{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_orderId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"_maxCost\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_fees\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"fillOrKillOrder\",\"outputs\":[],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"otherMethods\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
					"args": [
						"0x6bd55a2877890bd58871eefe886770a7734077a74981910a75d7b1f044b5bf28",
						"1000000000000000000",
						"[\"0x095aE61E8207C7856eA273235D6BAdb69d815F5e\", \"0xC9D9B33231d24dd8cC53fDD64F7ABdd156f2a7E2\"]",
						{
							"abi": "notExpired(uint256,string)",
							"args": [
								"1600000000",
								"Nov 1st, 2020"
							],
							"func": "notExpired"
						}
					],
					"func": "fillOrKillOrder"
				},
        "to": "0x140d72763D1ce39Ad4E2e73EC6e8FC53E5b73B64",
				"type": "delayedEncode",
        "value": "0"
			}
    ],
    "wallet": "0xBc5F07A5852fdF3DBd57A76835109220D0ADd8E8"
  },
  "signatures": [{
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696",
    "signature": "0x4f9555c73908b6a5b61e0a744cb4e00fce7b20743d5799e4cb1774081bc6b2ec192c740e50f1adec84605636e09c9cdf4d2f6629f9ce64d8d0f3ae10305ef90400"
  }]
}

Close session payload

This payload is generated when the client requests clossing a given session. Notice that the client MAY close the current session, or some other session.

NameTypeDescriptionOptional
codestringThe "code" of the payload (closeSession).No
walletstringAddress of the wallet.No
sessionstringIdentifier for the session to be closedNo
{
  "version": "1.0.0",
  "packet": {
    "code": "closeSession",
    "expires": 1600086400,
    "issued": 1600000000,
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696",
    "wallet": "0xBc5F07A5852fdF3DBd57A76835109220D0ADd8E8"
  },
  "signatures": [{
    "session": "0xCF67BCbD9D5DFD373b03f4fc8143e1c6744B5696",
    "signature": "0x4f9555c73908b6a5b61e0a744cb4e00fce7b20743d5799e4cb1774081bc6b2ec192c740e50f1adec84605636e09c9cdf4d2f6629f9ce64d8d0f3ae10305ef90400"
  }]
}