-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsignatureTypes.ts
47 lines (40 loc) · 1.45 KB
/
signatureTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { ethers } from "ethers";
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
import { ApiKeyCreds, Chain, ClobClient } from "../src";
import { SignatureType } from "@polymarket/order-utils";
dotenvConfig({ path: resolve(__dirname, "../.env") });
async function main() {
const wallet = new ethers.Wallet(`${process.env.PK}`);
const chainId = parseInt(`${process.env.CHAIN_ID || Chain.AMOY}`) as Chain;
console.log(`Address: ${await wallet.getAddress()}, chainId: ${chainId}`);
const host = process.env.CLOB_API_URL || "http://localhost:8080";
const creds: ApiKeyCreds = {
key: `${process.env.CLOB_API_KEY}`,
secret: `${process.env.CLOB_SECRET}`,
passphrase: `${process.env.CLOB_PASS_PHRASE}`,
};
// Client used with an EOA: Signature type 0
const clobClient = new ClobClient(host, chainId, wallet, creds);
// Client used with a Polymarket Proxy Wallet: Signature type 1
const proxyWalletAddress = "0x...";
const polyProxyClient = new ClobClient(
host,
chainId,
wallet,
creds,
SignatureType.POLY_PROXY,
proxyWalletAddress,
);
// Client used with a Polymarket Gnosis safe: Signature Type 2
const gnosisSafeAddress = "0x...";
const polyGnosisSafeClient = new ClobClient(
host,
chainId,
wallet,
creds,
SignatureType.POLY_GNOSIS_SAFE,
gnosisSafeAddress,
);
}
main();