Skip to content

Instantly share code, notes, and snippets.

@cordt-sei
cordt-sei / associate.ts
Last active December 12, 2024 14:22 — forked from besated/associate.ts
// Here are detailed **4** different methods with which a new account can be "associated" or "linked" on-chain
// In very clear terms, all this is doing is making the pubkey known to the chain.
// This is required because there is no way to determine either of the wallet addresses from the other.
import secp256k1 from "secp256k1";
import { createPublicClient, createWalletClient, hexToNumber, http, numberToHex, parseSignature, toHex } from "viem";
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
import { seiTestnet } from "viem/chains";
import { ADDRESS_PRECOMPILE_ABI, ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';