You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -106,23 +106,24 @@ The client that the user interacts with (web browser, mobile apps, etc) never in
106
106
107
107
For any action that requires blockchain interaction,
108
108
109
-
- Client requests an EIP712 formatted signature from the user
109
+
- Client requests an EIP-712 formatted signature from the user
110
110
- The signature is sent to a simple relayer server (should have a simple auth/spam protection if used for production, or biconomy's mexa sdk can be used: [https://github.com/bcnmy/mexa-sdk](https://github.com/bcnmy/mexa-sdk))
111
111
- The relayer interacts with the blockchain to submit user's signature to the contract. A function on the contract called `executeMetaTransaction` processes the signature and executes the requested transaction (via an internal call).
112
112
- The relayer pays for the gas making the transaction effectively free 🤑
113
113
114
-
## Integrate Network Agnostic Transactions in your dApp
114
+
## Integrate network agnostic transactions in your dApp
115
115
116
116
- Choose between a custom simple relayer node/biconomy.
117
117
118
-
- For biconomy, setup a dapp from the dashboard and save the api-id and api-key, see: [https://docs.biconomy.io/](https://docs.biconomy.io/)
118
+
- For Biconomy, setup a dapp from the dashboard and save the api-id and api-key, see: [https://docs.biconomy.io/](https://docs.biconomy.io/)
119
119
120
120
**Steps:**
121
121
122
-
1. Let's Register our contracts to biconomy dashboard
123
-
1. Visit the [official documents of biconomy](https://docs.biconomy.io/biconomy-dashboard).
124
-
2. While registering the dapp, select `Polygon Mumbai`
125
-
2. Copy the`API key` to use in frontend
122
+
1. Let's register our contracts to Biconomy dashboard
3. Select `Polygon Mumbai` when registering your dapp
126
+
2. Copy the`API key` to use for you dapp's frontend
126
127
3. And Add function `executeMetaTransaction` in Manage-Api and make sure to enable meta-tx. (Check 'native-metatx' option)
127
128
128
129
- If you'd like to use your own custom API that sends signed transactions on the blockchain, you can refer to the server code here: [https://github.com/angelagilhotra/ETHOnline-Workshop/tree/master/2-network-agnostic-transfer](https://github.com/angelagilhotra/ETHOnline-Workshop/tree/master/2-network-agnostic-transfer)
@@ -163,140 +164,140 @@ let data = await web3.eth.abi.encodeFunctionCall({
163
164
params: msgParams
164
165
});
165
166
166
-
```
167
-
168
-
- Once you have a relayer and the contracts setup, what is required is for the client to be able to fetch an EIP712 formatted signature and simply call the API with the required parameters
Calling the API, ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L110](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L110)
206
-
207
-
```jsx
208
-
const response = await request.post(
209
-
'http://localhost:3000/exec', {
210
-
json: txObj,
211
-
},
212
-
(error, res, body) => {
213
-
if (error) {
214
-
console.error(error)
215
-
return
216
-
}
217
-
document.getElementById(el).innerHTML =
218
-
`response:`+ JSON.stringify(body)
219
-
}
220
-
)
221
-
```
222
-
223
-
If using Biconomy, the following should be called:
- If you use the custom API it executes the `executeMetaTransaction`function on the contract:
169
+
- Once you have a relayer and the contracts set up, what is required is for the client to be able to fetch an EIP-712 formatted signature and simply call the API with the required parameters
Calling the API, ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L110](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L110)
207
+
208
+
```jsx
209
+
constresponse=awaitrequest.post(
210
+
'http://localhost:3000/exec', {
211
+
json: txObj,
212
+
},
213
+
(error, res, body) => {
214
+
if (error) {
215
+
console.error(error)
216
+
return
274
217
}
275
-
```
218
+
document.getElementById(el).innerHTML=
219
+
`response:`+JSON.stringify(body)
220
+
}
221
+
)
222
+
```
276
223
277
-
isusingbiconomy, theclientsidecalllookslike:
224
+
If using Biconomy, the following should be called:
let tx =awaitcontract.methods.executeMetaTransaction(
266
+
txDetails.from, txDetails.fnSig, r, s, v
267
+
).send ({
268
+
from: user,
269
+
gas:800000
270
+
})
271
+
req.txHash=tx.transactionHash
272
+
} catch (err) {
273
+
console.log (err)
274
+
next(err)
275
+
}
276
+
```
277
+
278
+
is using biconomy, the client side call looks like:
279
+
280
+
```jsx
281
+
// client/src/App.js
282
+
importReactfrom"react";
283
+
importBiconomyfrom"@biconomy/mexa";
284
+
285
+
constgetWeb3=newWeb3(biconomy);
286
+
biconomy
287
+
.onEvent(biconomy.READY, () => {
288
+
// Initialize your dapp here like getting user accounts etc
289
+
console.log("Mexa is Ready");
290
+
})
291
+
.onEvent(biconomy.ERROR, (error, message) => {
292
+
// Handle error while initializing mexa
293
+
console.error(error);
294
+
});
295
+
296
+
/**
297
+
* use the getWeb3 object to define a contract and calling the function directly
298
+
*/
299
+
300
+
```
300
301
301
302
Account Abstraction is a blockchain technology that enables users to utilize smart contracts as their accounts. While the default account for most users is an Externally Owned Account (EOA), which is controlled by an external private key, it requires users to have a considerable understanding of blockchain technology to use them securely. Fortunately, smart contract accounts can create superior user experiences.
-**Account security:** Contract accounts enable social recovery and security features such as time-locks and withdraw limits.
310
311
-**Atomic multi-operations:** Users can perform multiple operations simultaneously, such as trading in a single click instead of approving and swapping separately.
311
312
312
-
## UsingAccountAbstractiononPolygon
313
+
## Using account abstraction on Polygon
313
314
314
315
There are two primary ways users can use account abstraction on Polygon: by sending ERC-4337 transactions or with third party meta transaction services.
315
316
316
317
### ERC-4337
317
318
318
319
ERC-4337, also known is EIP-4337, brings account abstraction to the Polygon ecosystem and all EVM-compatible chains.
319
320
320
-
### MetaTransactions
321
+
### Meta transactions
321
322
322
323
Meta transactions are bespoke third party services for achieving account abstraction.
0 commit comments