Skip to content

Instantly share code, notes, and snippets.

@koolamusic
Forked from ajb413/delegate-sign.js
Created December 17, 2021 01:37
Show Gist options
  • Save koolamusic/aaae509ab24d47cda70e749716f68d4f to your computer and use it in GitHub Desktop.
Save koolamusic/aaae509ab24d47cda70e749716f68d4f to your computer and use it in GitHub Desktop.
const createDelegateBySigMessage = (compAddress, delegatee, expiry = 10e9, chainId = 1, nonce = 0) => {
const types = {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Delegation: [
{ name: 'delegatee', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'expiry', type: 'uint256' }
]
};
const primaryType = 'Delegation';
const domain = { name: 'Compound', chainId, verifyingContract: compAddress };
const message = { delegatee, nonce, expiry };
return JSON.stringify({ types, primaryType, domain, message });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment