etherspot / etherspot-prime-sdk

Etherspot Prime - Account Abstraction SDK
https://etherspot.fyi
MIT License
119 stars 21 forks source link

[BUG] this library work in server side nodejs api #79

Closed francelwebdev closed 8 months ago

francelwebdev commented 8 months ago

Describe the bug

I'm getting this error on : await primeSdk.estimate()

checking nonce... 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ErrorHandler = void 0; 4 | const constants_1 = require("./constants"); 5 | class ErrorHandler extends Error { 6 | constructor(error, code) { 7 | super(error); ^ error: AA21 didn't pay prefund code: "-32500"

  at new ErrorHandler (/home/francel/Bureau/etherspot_prime_test/node_modules/@etherspot/prime-sdk/dist/sdk/errorHandler/errorHandler.service.js:7:8)
  at /home/francel/Bureau/etherspot_prime_test/node_modules/@etherspot/prime-sdk/dist/sdk/base/HttpRpcClient.js:41:22
  at processTicksAndRejections (:61:76)

Expected behavior

Work well inserver side nodejs

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Prime SDK version or commit hash

latest

ch4r10t33r commented 8 months ago

I'm getting this error on : await primeSdk.estimate()

checking nonce... 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ErrorHandler = void 0; 4 | const constants_1 = require("./constants"); 5 | class ErrorHandler extends Error { 6 | constructor(error, code) { 7 | super(error); ^ error: AA21 didn't pay prefund code: "-32500"

This is a valid error which means the wallet you are using doesn't have enough balance to pay for the gas. I suggest you look at examples provided in https://github.com/etherspot/etherspot-prime-sdk/examples and work from there.

ch4r10t33r commented 8 months ago

Please refer to https://etherspot.fyi/contracts/error-codes that lists all the common error codes.

francelwebdev commented 8 months ago

ok thanks

francelwebdev commented 8 months ago

I thought that even if there is no balance on the SCW address it would still send me the estimate of the gas cost for the transaction.

francelwebdev commented 8 months ago

I'm building a hybrid dapps (web2 and web3). I have a vuejs frontend and a nodejs backend. When a user registers on the frontend with email and password I create a SCW for him and the user will have to deposit for example USDT OR USDC on the SCW address to be sold.

It is a p2p platform for buying and selling cryptocurrency.

When a buyer purchases and pays, the purchased USDT or USDC will be transferred from the seller's SCW automatically to the buyer's EOA address.

francelwebdev commented 8 months ago

so I need a SCW for sellers and a way to pay transaction fees with for example USDT or USDC or cover transaction fees via a paymasters.

francelwebdev commented 8 months ago

so there must be a balance on the SCW address before you can know the cost of gas for a transaction?