-
-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add biconomy bundler URL * Update bundler.md * Update site/pages/account-abstraction.mdx Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/estimateUserOperationGas.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/getChainId.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/getSupportedEntryPoints.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/getUserOperation.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/prepareUserOperation.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/sendUserOperation.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/waitForUserOperationReceipt.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/clients/bundler.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/guides/sending-user-operations.md Co-authored-by: awkweb <[email protected]> * Update site/pages/account-abstraction/actions/bundler/getUserOperationReceipt.md Co-authored-by: awkweb <[email protected]> * Add biconomy bundler example * chore: tweaks * chore: format --------- Co-authored-by: jxom <[email protected]> Co-authored-by: awkweb <[email protected]> Co-authored-by: jxom <[email protected]>
- Loading branch information
1 parent
e857d95
commit a6576a9
Showing
7 changed files
with
162 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Biconomy Bundler Example | ||
|
||
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/wevm/viem/tree/main/examples/account-abstraction_biconomy-bundler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
</head> | ||
<body> | ||
<h1>Biconomy Bundler Example</h1> | ||
<div id="app"><button>Send User Operation</button></div> | ||
<script type="module"> | ||
document.querySelector('button').addEventListener('click', async () => { | ||
document.querySelector('#app').innerHTML = 'Sending...' | ||
const response = await import('./index.ts').then((x) => x.default); | ||
document.querySelector('#app').innerHTML = response | ||
.map((x) => `<div style="margin-top: 16px;">${x}</div>`) | ||
.join(''); | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { http, type Hex, createPublicClient, parseEther } from 'viem' | ||
import { | ||
createBundlerClient, | ||
createPaymasterClient, | ||
toCoinbaseSmartAccount, | ||
} from 'viem/account-abstraction' | ||
import { privateKeyToAccount } from 'viem/accounts' | ||
import { sepolia } from 'viem/chains' | ||
|
||
const client = createPublicClient({ | ||
chain: sepolia, | ||
transport: http(), | ||
}) | ||
|
||
const owner = privateKeyToAccount(import.meta.env.VITE_PRIVATE_KEY as Hex) | ||
|
||
const account = await toCoinbaseSmartAccount({ | ||
client, | ||
owners: [owner], | ||
}) | ||
|
||
const paymasterClient = createPaymasterClient({ | ||
transport: http( | ||
'https://paymaster.biconomy.io/api/v1/11155111/kxBB8jbLI.fb3e07cf-c4cd-4d20-8503-c396e405b0df', | ||
), | ||
}) | ||
|
||
const bundlerClient = createBundlerClient({ | ||
account, | ||
client, | ||
transport: http( | ||
'https://bundler.biconomy.io/api/v2/11155111/kxBB8jbLI.fb3e07cf-c4cd-4d20-8503-c396e405b0df', | ||
), | ||
paymaster: paymasterClient, | ||
paymasterContext: { | ||
mode: 'SPONSORED', | ||
calculateGasLimits: true, | ||
expiryDuration: 300, | ||
sponsorshipInfo: { | ||
webhookData: {}, | ||
smartAccountInfo: { | ||
name: 'BICONOMY', | ||
version: '2.0.0', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const hash = await bundlerClient.sendUserOperation({ | ||
calls: [ | ||
// send 0.000001 ETH to self | ||
{ | ||
to: account.address, | ||
value: parseEther('0.000001'), | ||
}, | ||
], | ||
}) | ||
|
||
export default [`User Operation Hash: ${hash}`] |
15 changes: 15 additions & 0 deletions
15
examples/account-abstraction_biconomy-bundler/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "example-biconomy-bundler", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite" | ||
}, | ||
"dependencies": { | ||
"viem": "latest" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.0.3", | ||
"vite": "^4.4.5" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/account-abstraction_biconomy-bundler/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM"], | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"noEmit": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src"] | ||
} | ||
|
Oops, something went wrong.