1.0.0 • Published 2 years ago
zeconomy-abstract-account-sdk v1.0.0
To initialize abstract account
This will depend on which everway you import it
const AbstractAccount = require("../src/abstract-account-zec-sdk")
const abstractAccount = new AbstractAccount(ethRPC, bundlerRPC, signerKey, signerPubKey, entryPoint, factoryAddress, abi)
/**
ethRPC: The ethereum RPC such as the dev RPC
bundlerRPC: The RPC to connect to the bundler's node
signerKey: The private key to be used to create abstract accounts and to sign transactions
signerPubKey: The public key for the private key to be used to create abstract accounts and to sign transactions
entryPoint: The entrypoint address
factoryAddress: The address of the factory contract
abi: The abstract contract ABI
*/
const proxyAddress = await abstractAccount.deployAccount(bytecode, passphrase) // you will be provided with the bytecode. The passphrase will be provided by the user
// create USER op. This is an example
/**
* @param sender: The account making the operation
* @param nonce: Anti-replay parameter for signature
* @param initCode: for account creation. leave it at the default value "0x"
* @param callData: The data to pass to the sender during the main execution call
* @param verificationGasLimit: The amount of gas to allocate for the verification step
* @param preVerificationGas: The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata
* @param maxFeePerGas: Maximum fee to be paid per gas. We can use the network's gas price here
* @param maxPriorityFeePerGas: Maximum priority fee per gas. Can be the same value with maxFeePerGas
* @param paymasterAndData: Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster. ( We don't have this so we can use "0x" as default )
* @param signature: Data passed into the account along with the nonce during the verification step ( Don't worry about this field, the SDK will handle this part. Pass "0x" as default )
*/
let userOp = {
"sender": walletAccount,
"nonce": "0x0",
"initCode": "0x",
"callData": calldata,
"callGasLimit": "0x650b1",
"verificationGasLimit": "0x650b1",
"maxFeePerGas": "0x6507a5e0",
"maxPriorityFeePerGas": "0x6507a5e0",
"paymasterAndData": "0x",
"preVerificationGas": "0x650b1",
"passPhrase": "access",
"signature": "0x"
}
// send to Bundler
opHash = await abstractAccount.sendToBundler(userOp) // a returned ophash signifies a successful execution
1.0.0
2 years ago