@@ -9,7 +9,7 @@ class PaymasterProvider extends ethers.providers.JsonRpcProvider {
9
9
const params = [ {
10
10
to : transaction . to ,
11
11
from : transaction . from ,
12
- value : ethers . utils . hexlify ( transaction . value ) ,
12
+ value : transaction . value != null ? ethers . utils . hexlify ( transaction . value ) : '0x0' ,
13
13
gas : ethers . utils . hexlify ( transaction . gasLimit || 0 ) ,
14
14
data : transaction . data || '0x'
15
15
} ] ;
@@ -21,11 +21,11 @@ class PaymasterProvider extends ethers.providers.JsonRpcProvider {
21
21
22
22
async function sendERC20Transaction ( ) {
23
23
// Replace with your private key (be cautious with private keys!)
24
- const privateKey = 'YOUR_PRIVATE_KEY ' ;
24
+ const privateKey = '' ;
25
25
// replace with your ERC20 receiver
26
- const toAddress = 'RECIPIENT_ADDRESS ' ;
26
+ const toAddress = '0x.. ' ;
27
27
// 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.. ' ;
29
29
30
30
31
31
// Provider for assembling the transaction (e.g., mainnet)
@@ -59,7 +59,7 @@ async function sendERC20Transaction() {
59
59
transaction . gasLimit = 100000 ; // Adjust gas limit as needed for token transfers
60
60
61
61
try {
62
- const sponsorableInfo = await provider . isSponsorable ( transaction ) ;
62
+ const sponsorableInfo = await paymasterProvider . isSponsorable ( transaction ) ;
63
63
console . log ( 'Sponsorable Information:' , sponsorableInfo ) ;
64
64
} catch ( error ) {
65
65
console . error ( 'Error checking sponsorable status:' , error ) ;
@@ -69,8 +69,8 @@ async function sendERC20Transaction() {
69
69
const signedTx = await wallet . signTransaction ( transaction ) ;
70
70
71
71
// 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 ) ;
74
74
75
75
} catch ( error ) {
76
76
console . error ( 'Error sending transaction:' , error ) ;
0 commit comments