11const axios = require ( 'axios' ) ;
2- const { http, createPublicClient } = require ( 'viem' ) ;
2+
3+ const { worldchain } = require ( 'viem/chains' ) ;
4+ const { http, createPublicClient, createWalletClient } = require ( 'viem' ) ;
35const { privateKeyToAccount } = require ( 'viem/accounts' ) ;
46
57const CHAIN_ID = 480 ;
6- const USER_PRIZE_VAULT_ADDRESS = '0x4c7e1f64a4b121d2f10d6fbca0db143787bf64bb ' ;
8+ const USER_PRIZE_VAULT_ADDRESS = '0x4c7E1f64A4b121D2F10D6FbcA0DB143787BF64bB ' ;
79const WORLD_TOKEN_ADDRESS = '0x2cFc85d8E48F8EAB294be644d9E25C3030863003' ;
810const MERKL_DISTRIBUTOR_CONTRACT_ADDRESS = '0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae' ;
911
@@ -55,17 +57,21 @@ async function sendTransaction(claimData) {
5557 // Merkl Distributor Proxy Contract
5658 const users = [ USER_PRIZE_VAULT_ADDRESS ] ;
5759 const tokens = [ WORLD_TOKEN_ADDRESS ] ;
58- const amounts = [ claimData . unclaimed ] ;
60+ const amounts = [ claimData . accumulated ] ;
5961 const proofs = [ claimData . proof ] ;
6062
6163 try {
6264 const account = privateKeyToAccount ( `0x${ privateKey } ` ) ;
6365 const publicClient = createPublicClient ( {
64- chain : 480 , // You can specify a chain if needed, e.g., mainnet, goerli, etc.
66+ chain : worldchain ,
67+ transport : http ( rpcUrl ) ,
68+ } ) ;
69+ const walletClient = createWalletClient ( {
70+ chain : worldchain ,
6571 transport : http ( rpcUrl ) ,
72+ account,
6673 } ) ;
6774
68- // Simulate the transaction
6975 const { request } = await publicClient . simulateContract ( {
7076 address : MERKL_DISTRIBUTOR_CONTRACT_ADDRESS ,
7177 abi : CLAIM_ABI ,
@@ -74,11 +80,9 @@ async function sendTransaction(claimData) {
7480 account,
7581 } ) ;
7682
77- // Execute the transaction
78- const hash = await publicClient . writeContract ( request ) ;
83+ const hash = await walletClient . writeContract ( request ) ;
7984 console . log ( 'Transaction hash:' , hash ) ;
8085
81- // Optionally, you can wait for the transaction receipt
8286 const transactionReceipt = await publicClient . waitForTransactionReceipt ( { hash } ) ;
8387 console . log ( 'Transaction receipt:' , transactionReceipt ) ;
8488 } catch ( err ) {
0 commit comments