Signatures
TypeScript. Light signatures in TypeScript can be created using the @airswap/utils package.
1
import { UnsignedLightOrder } from '@airswap/types'
2
import { createLightOrder, createLightSignature } from '@airswap/utils'
3
4
const order = createLightOrder({
5
nonce: string,
6
expiry: string,
7
signerWallet: string,
8
signerToken: string,
9
signerAmount: string,
10
signerFee: string,
11
senderWallet: string,
12
senderToken: string,
13
senderAmount: string,
14
})
15
16
const { v, r, s } = createLightSignature(
17
order: UnsignedLightOrder,
18
privateKey: string,
19
swapContract: string,
20
chainId: string,
21
)
Copied!
Python. Light signatures in Python can be created using the py_eth_sig_utils package.
1
from py_eth_sig_utils.signing import *
2
3
SIGNER_KEY = "0000000000000000000000000000000000000000000000000000000000000000"
4
SWAP_CONTRACT = "0x0000000000000000000000000000000000000000"
5
6
DOMAIN = "SWAP_LIGHT"
7
VERSION = "3"
8
CHAIN_ID = 1
9
10
order = {
11
"nonce": 0,
12
"expiry": 0,
13
"signerWallet": "0x0000000000000000000000000000000000000000",
14
"signerToken": "0x0000000000000000000000000000000000000000",
15
"signerAmount": 0,
16
"signerFee": 0,
17
"senderWallet": "0x0000000000000000000000000000000000000000",
18
"senderToken": "0x0000000000000000000000000000000000000000",
19
"senderAmount": 0
20
}
21
22
data = {
23
"types": {
24
"EIP712Domain": [
25
{ "name": "name", "type": "string" },
26
{ "name": "version", "type": "string" },
27
{ "name": "chainId", "type": "uint256" },
28
{ "name": "verifyingContract", "type": "address" },
29
],
30
"LightOrder": [
31
{ "name": "nonce", "type": "uint256" },
32
{ "name": "expiry", "type": "uint256" },
33
{ "name": "signerWallet", "type": "address" },
34
{ "name": "signerToken", "type": "address" },
35
{ "name": "signerAmount", "type": "uint256" },
36
{ "name": "signerFee", "type": "uint256" },
37
{ "name": "senderWallet", "type": "address" },
38
{ "name": "senderToken", "type": "address" },
39
{ "name": "senderAmount", "type": "uint256" },
40
]
41
},
42
"domain": {
43
"name": DOMAIN,
44
"version": VERSION,
45
"chainId": CHAIN_ID,
46
"verifyingContract": SWAP_CONTRACT,
47
},
48
"primaryType": "LightOrder",
49
"message": order,
50
}
51
52
v, r, s = sign_typed_data(data, bytes.fromhex(SIGNER_KEY))
Copied!

Authorized Signers

Optional. One account may authorize another account to sign orders on its behalf. For example, a server might sign using an account that has been authorized by a contract wallet. To manage signer authorizations, use the following functions on the Light contract.
1
function authorize(address signer) external
2
function revoke() external
Copied!

EIP712

The following values are used for the EIP712Domain.
Param
Type
Value
name
bytes32
SWAP_LIGHT
version
bytes32
3
chainId
uint256
Ethereum Mainnet: 1, Rinkeby: 4
verifyingContract
address
Light contract address
Last modified 1mo ago
Copy link