TESTNET ONLINE: PECORINO PECORINO
⚠️ Restricted Access

This documentation is not publicly listed. Please do not share access URLs with unauthorized individuals.

Signed Orders

Signing Orders

Signet’s Permit2 integration enhances token transfers by enabling intent-based orders with user signatures and Filler submissions.

Constructing Token Transfers

Assemble Data

Create the outputs array specifying the tokens, amounts, recipients, and destination chain IDs. Construct the permit object listing permitted tokens and amounts, along with the nonce and deadline.

Generate Witness Hash

Hash the outputs array to create a witness hash, ensuring the integrity of the transaction details.

Hash Permit Data

Combine the permit data with the witness hash and hash the result. This step binds the permit to the specific transaction details.

Sign Data and Encode Signature

Sign the final hashed data using your private key.

JSON Example

 1{
 2   "outputs": [
 3      {
 4          "token": "0xtokenaddress",
 5          "amount": 100000,
 6          "recipient": "0xrecipientaddress",
 7          "chainId": 17000
 8      },
 9      {
10          "token": "0xtokenaddress",
11          "amount": 100000,
12          "recipient": "0xrecipientaddress",
13          "chainId": 17001
14      }
15   ],
16   "permit": {
17      "permitted": [
18         {
19            "token": "0xtokenaddress",
20            "amount": 100000
21         },
22         {
23            "token": "0xtokenaddress",
24            "amount": 100000
25         }
26      ],
27      "nonce": 0,
28      "deadline": 123456789
29   },
30   "owner": "0xsigneraddress",
31   "signature": "0xpackedVRSsignature"
32}

Submitting a Signed Order

Use the initiatePermit2 function to submit the signed order. Pass the outputs array and the permit2 object containing the permit data, owner address, and signature.

Solidity Function Interface: InitiatePermit2

1function initiatePermit2(
2    address tokenRecipient, // Filler-submitted
3    Output[] memory outputs,  // signed
4    OrdersPermit2.Permit2Batch calldata permit2 // signed
5) external;

Ensure that the outputs and permit2 structs are correctly formatted and signed and validate the nonce to prevent replay attacks and check the deadline for transaction validity.

Filling Orders

Use the fillPermit2 function to process the order and transfer the specified tokens.

Solidity Function Interface: fillPermit2

1function fillPermit2(
2    Output[] memory outputs,
3    OrdersPermit2.Permit2Batch calldata permit2
4) external;

The permit.permitted array acts as the outputs and must match the order exactly for the transaction to proceed.

Ensure that the format and structures used for filling orders are consistent with those used for submitting orders.

Solidity Structs

Struct: Output

1struct Output {
2    address token; // ERC20 token address on the destination chain
3    uint256 amount; // Amount of the token to be sent
4    address recipient; // Address to receive the output tokens
5    uint32 chainId; // Destination chain ID for the Output
6}

Struct: Permit2Batch

1struct Permit2Batch {
2    ISignatureTransfer.PermitBatchTransferFrom permit;
3    address owner;
4    bytes signature;
5}

Struct: PermitBatchTransferFrom

1struct PermitBatchTransferFrom {
2    TokenPermissions[] permitted;
3    uint256 nonce;
4    uint256 deadline;
5}

Struct: TokenPermissions

1struct TokenPermissions {
2    address token; // ERC20 token address
3    uint256 amount; // Maximum amount that can be spent
4}

Non-linear nonce: Each nonce is unique and does not have to follow a sequential order. This design prevents replay attacks and increases transaction security.