Signing Orders
Method
Example
from random import randint
from eip712_structs import EIP712Struct, Address, Uint, Boolean, make_domain
from web3 import Web3
from eth_account import Account
# Generate Salt
salt = randint(0, 10**6)
# Limit price and amount is in 6 decimal places
decimals = 10**6
limit_price = int(100 * decimals) # Limit price of $100
amount = int(2 * decimals) # Size of 2 contracts
# Current timestamp in UNIX seconds
timestamp = 1690434000
# instrument_id from /options-chain
instrument = 1
class Order(EIP712Struct):
maker = Address()
isBuy = Boolean()
limitPrice = Uint(256)
amount = Uint(256)
salt = Uint(256)
instrument = Uint(256)
timestamp = Uint(256)
order_struct = Order(maker="your_address", # The wallet's main address
isBuy=True, # True if buy, False if sell
limitPrice=limit_price,
amount=amount,
salt=salt,
instrument=instrument,
timestamp=timestamp)
# Get bytes
domain = make_domain(name="Aevo Mainnet", version="1", chainId=1)
# Testnet Domain
# domain = make_domain(name='Aevo Testnet', version='1', chainId=11155111)
signable_bytes = Web3.keccak(order_struct.signable_bytes(domain=domain))
# Sign with key
key = "your_signing_key"
signature = Account._sign_hash(signable_bytes, key).signature.hex()Last updated