@abstraction-hq/wallet-sdk
v1.0.8
Published
Interact your app with top tier wallet on blockchain.
Downloads
14
Maintainers
Readme
Abstraction Wallet SDK
Abstraction wallet SDK allow developers connect their Dapps to Abstraction Wallet via EIP-6963
Install Abstraction Wallet SDK
# yarn
yarn add @abstraction-hq/wallet-skd
# npm
npm install @abstraction-hq/wallet-sdk
Basic Usage
Init provider with EIP-6963
import { initAbstractionWallet } from "@abstraction-hq/wallet-sdk";
initAbstractionWallet();
Create provider
import { createAbstractionProvider } from "@abstraction-hq/wallet-sdk";
const provider = createAbstractionProvider();
Use provider
- Connect Wallet
const addresses = provider.request({
method: "eth_requestAccounts",
});
- Send Transaction
const txHash = await(window as any).abstraction.request({
method: "eth_sendTransaction",
params: [
{
from: address,
to: address,
value: 0,
data,
},
],
});
- Sending multiple calls
const userOpHash = await(window as any).abstraction.request({
method: "wallet_sendCalls",
params: [
{
version: "1.0",
chainId: "0x58",
from: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
calls: [
{
to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
value: "0x9184e72a",
data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
},
{
to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
value: "0x9184e72a",
data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
},
]
}
],
});
- Get call status
const callStatus = await(window as any).abstraction.request({
method: "wallet_getCallsStatus",
params: [
userOpHash
],
});
- Create contract
const txHash = await(window as any).abstraction.request({
method: "eth_sendTransaction",
params: [
{
from: address,
value: 0,
data: CONTRACT_BYTECODE,
},
],
salt: // Salt to create contract with create2 - account.nonce() if not provide
});