File tree 1 file changed +24
-19
lines changed
examples/SafeAccountExamples/CreateAccountAndSendTransactionUsingTokenPaymaster/src
1 file changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -80,26 +80,31 @@ async function main(): Promise<void> {
80
80
paymasterRPC ,
81
81
)
82
82
83
- userOperation = await paymaster . createTokenPaymasterUserOperation (
84
- smartAccount ,
85
- userOperation ,
86
- paymasterTokenAddress ,
87
- bundlerUrl ,
88
- )
83
+ const tokensSupported = await paymaster . fetchSupportedERC20TokensAndPaymasterMetadata ( ) ;
84
+ const tokenSelected = tokensSupported . tokens . find ( token => token . address . toLocaleLowerCase ( ) === paymasterTokenAddress . toLowerCase ( ) ) ;
89
85
90
- const cost = await paymaster . calculateUserOperationErc20TokenMaxGasCost (
91
- userOperation ,
92
- paymasterTokenAddress
93
- )
94
- console . log ( "This useroperation may cost upto : " + cost + " wei in CTT token" )
95
- console . log (
96
- "Please fund the sender account : " +
97
- userOperation . sender +
98
- " with more than " + cost + " wei CTT token"
99
- )
100
- console . log ( "This example uses a Candide token paymaster." )
101
- console . log ( "Please visit https://dashboard.candide.dev/ to get a token paymaster url." )
102
- console . log ( "Please visit our Discord to get some CTT token for testing" )
86
+ console . log ( "This example uses Candide Token Paymaster" ) ;
87
+ console . log ( "Please visit https://dashboard.candide.dev/ to get a Paymaster URL" ) ;
88
+ console . log ( "Visit our Discord to get some CTT token for testing" ) ;
89
+
90
+ if ( tokenSelected ) {
91
+ userOperation = await paymaster . createTokenPaymasterUserOperation (
92
+ smartAccount ,
93
+ userOperation ,
94
+ tokenSelected . address ,
95
+ bundlerUrl ,
96
+ )
97
+ const cost = await paymaster . calculateUserOperationErc20TokenMaxGasCost (
98
+ userOperation ,
99
+ tokenSelected . address ,
100
+ )
101
+ console . log ( "This useroperation may cost upto : " + cost + " wei in CTT token" )
102
+ console . log (
103
+ "Please fund the sender account : " +
104
+ userOperation . sender +
105
+ " with more than " + cost + " wei CTT token"
106
+ )
107
+ }
103
108
104
109
//Safe is a multisig that can have multiple owners/signers
105
110
//signUserOperation will create a signature for the provided
You can’t perform that action at this time.
0 commit comments