Package Exports
- @polymarket/builder-abstract-signer
- @polymarket/builder-abstract-signer/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@polymarket/builder-abstract-signer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
abstract-signer
Abstraction over the ethers v5 Wallet, ethers v5 JsonRpcSigner or Viem WalletClient
Installation
pnpm install @polymarket/abstract-signerUsage
import { ethers } from "ethers";
import { createWalletClient, http} from "viem";
import { privateKeyToAccount } from 'viem/accounts';
import { createAbstractSigner, IAbstractSigner, Transaction } from "@polymarket/abstract-signer";
const chainId = parseInt(`${process.env.CHAIN_ID}`);
// ethers
// Instantiate an ethers Wallet
const provider = new ethers.providers.JsonRpcProvider(`${process.env.RPC_URL}`);
const pk = new ethers.Wallet(`${process.env.PK}`);
const wallet = pk.connect(provider);
// viem
// Instantiate a Viem wallet
const account = privateKeyToAccount(`${process.env.PK}`);
const wallet = createWalletClient({
account: account,
transport: http(`${process.env.RPC_URL}`)
});
const abstractSigner: IAbstractSigner = createAbstractSigner(chainId, wallet);
const tx : Transaction = {
to: await abstractSigner.getAddress(),
value: 10000000000000000n,
gasPrice: 100000000000n,
};
const txHash = await abstractSigner.sendTransaction(tx);
console.log(`Tx hash: ${txHash}`);
const receipt = await abstractSigner.waitTillMined(txHash);
console.log(receipt);