Skip to content

Commit de910f3

Browse files
committed
fix code
1 parent b262345 commit de910f3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

js-example/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PaymasterProvider extends ethers.providers.JsonRpcProvider {
99
const params = [{
1010
to: transaction.to,
1111
from: transaction.from,
12-
value: ethers.utils.hexlify(transaction.value),
12+
value: transaction.value != null ? ethers.utils.hexlify(transaction.value) : '0x0',
1313
gas: ethers.utils.hexlify(transaction.gasLimit || 0),
1414
data: transaction.data || '0x'
1515
}];
@@ -21,11 +21,11 @@ class PaymasterProvider extends ethers.providers.JsonRpcProvider {
2121

2222
async function sendERC20Transaction() {
2323
// Replace with your private key (be cautious with private keys!)
24-
const privateKey = 'YOUR_PRIVATE_KEY';
24+
const privateKey = '';
2525
// replace with your ERC20 receiver
26-
const toAddress = 'RECIPIENT_ADDRESS';
26+
const toAddress = '0x..';
2727
// ERC20 token contract address (replace with the address of the token you want to send)
28-
const tokenAddress = 'TOKEN_CONTRACT_ADDRESS';
28+
const tokenAddress = '0x..';
2929

3030

3131
// Provider for assembling the transaction (e.g., mainnet)
@@ -59,7 +59,7 @@ async function sendERC20Transaction() {
5959
transaction.gasLimit = 100000; // Adjust gas limit as needed for token transfers
6060

6161
try {
62-
const sponsorableInfo = await provider.isSponsorable(transaction);
62+
const sponsorableInfo = await paymasterProvider.isSponsorable(transaction);
6363
console.log('Sponsorable Information:', sponsorableInfo);
6464
} catch (error) {
6565
console.error('Error checking sponsorable status:', error);
@@ -69,8 +69,8 @@ async function sendERC20Transaction() {
6969
const signedTx = await wallet.signTransaction(transaction);
7070

7171
// Send the raw transaction using the sending provider
72-
const tx = await paymasterProvider.sendTransaction(signedTx);
73-
console.log('Transaction sent:', tx.hash);
72+
const tx = await paymasterProvider.send('eth_sendRawTransaction', [signedTx]);
73+
console.log('Transaction sent:', tx);
7474

7575
} catch (error) {
7676
console.error('Error sending transaction:', error);

0 commit comments

Comments
 (0)