-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.ts
43 lines (35 loc) · 1.21 KB
/
transfer.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
import { farcaster, provider } from "./common";
import { ethers } from "ethers";
(async () => {
const ownerPrivateKey = 'PRIVATE_KEY';
const toPrivateKey = 'PRIVATE_KEY'
const ownerWallet = new ethers.Wallet(ownerPrivateKey, provider);
const toWallet = new ethers.Wallet(toPrivateKey, provider);
const deadline = BigInt(Math.floor(Date.now() / 1000) + (3600 * 24));
const nonce = await farcaster.getNonceIdRegistry(toWallet.address);
const fid = await farcaster.getIdOf(ownerWallet.address)
const signature = await farcaster.signTransfer(
fid,
toWallet.address,
nonce,
deadline,
toWallet
)
console.log(`fid: ${fid}`);
console.log(signature)
const calldata = await farcaster.contracts.idRegistry.populateTransaction.transfer(
toWallet.address,
deadline,
signature
)
const registerFidTxParam = {
from: ownerWallet.address,
to: farcaster.contractAddresses.ID_REGISTRY_ADDRESS,
data: calldata.data,
value: 0,
gasLimit: 10000000n
}
const tx = await ownerWallet.sendTransaction(registerFidTxParam);
const receipt = await tx.wait();
console.log(receipt);
})()