Securing with signatures
The Loop smart contract validates all transfer requests sent to it by validating that the message signer matches the signer address that is stored in the contact. If the signer values don't match, the transfer request fails and the contract moves onto the next transfer request.
This validation is performed regardless of whether a Company has delegated signing of on-chain transactions to Loop, or whether a Company optionally has elected to sign transfer requests themselves.
All transfer requests must be signed in accordance with EIP-712.
Transfer request data structure
The JSON structure of the transfer request object is as follows:
From which we can derive the following data structure:
Domain separator
The domain separator ensures that the signatures generated for transfer requests are only compatible with the Loop smart contract
Attribute | Value | Description |
---|---|---|
|
| The name of the application |
|
| The current version of the signing domain |
| Network dependent | The EIP-155 chain id. This prevents a signature meant for one network from working on another |
| Network dependent | The contract address that will verify the signature |
Putting it all together with code
This example code is written in Javascript and shows how to use the domain, types and message content together to sign and generate a signature using the EIP-712 standard.
1. Define the domain data, example uses Polygon as the network:
2. Define the data types:
3. Define the message:
4. Sign the message using ethers:
Note: If using ethers V5, the signTypedData
function is prefixed with an underscore:
Last updated