-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
903 additions
and
614 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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"] | ||
} | ||
|
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
Oops, something went wrong.