Skip to content

Commit 5f6d03c

Browse files
authored
Merge pull request 0xPolygon#165 from 0xPolygon/yongyi-updates
PoS - Broken links, copy edits
2 parents 6554835 + 90b8ea9 commit 5f6d03c

File tree

2 files changed

+147
-146
lines changed

2 files changed

+147
-146
lines changed

docs/pos/concepts/transactions/meta-transactions.md

Lines changed: 142 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ DApps are starting to realize their utility but are becoming victims of their su
33
success due to gas fees. Not to mention, the onboarding hurdles of users and the challenges of current
44
UX are no easy fix.
55

6-
## Servicing Smart Contracts
6+
## Servicing smart contracts
77

88
By design, smart contracts are deterministic state machines that execute when transaction fees are
99
paid to service the contract’s logic by using the network’s computational resources.
1010
This is accomplished by a gas-metered model on Ethereum (and Polygon).
1111

12-
## The Current State of Transacting
12+
## The current state of sransacting
1313

1414
There are limitations to this traditional transaction model on Ethereum (and other blockchains alike).
1515
A common limitation is a user not having the means to pay for gas. By default, the sender of the
@@ -25,7 +25,7 @@ experience.
2525
Instead of direct transaction execution, a middleware would exist (via a third party) to handle the gas.
2626
This is where meta transactions come in.
2727

28-
## What are Meta Transactions?
28+
## What are meta transactions?
2929

3030
Meta transactions allow anyone to interact with the blockchain. They do not require users to have
3131
tokens to pay for the network’s services through transaction fees. This is done by decoupling the
@@ -60,7 +60,7 @@ the “sender”, the “sender” becomes more like an “intender” - the sen
6060
they would like executed on the blockchain by signing a message containing specific parameters related to
6161
their message, and not an entirely constructed transaction.
6262

63-
## Use Cases
63+
## Use cases
6464

6565
One can imagine the capabilities of meta transactions for scaling dApps and interactions with smart contracts.
6666
Not only can a user create a gasless transaction, but they can also do so many times, and with an automation
@@ -81,15 +81,15 @@ validates that this transaction is a priority vote, wraps the voting request int
8181
pays the gas fees, and broadcasts it to the voting contract. Everything checks out on the voting contract’s
8282
end, and the vote executes on behalf of the user.
8383

84-
## Try Them Out
84+
## Try 'em out
8585

8686
Assuming your familiarity with the different approaches you can take to integrate meta transactions in your
8787
dApp, and depending on whether you're migrating to meta transactions or building fresh dApp on using it.
8888

8989
To integrate your dApp with Meta Transactions on Polygon, you can choose to go with one of the following
9090
relayers or spin up a custom solution:
9191

92-
- [Biconomy](https://docs.biconomy.io/products/enable-gasless-transactions)
92+
- [Biconomy](https://docs.biconomy.io/Account/transactions/gasless)
9393
- [Gas Station Network (GSN)](https://docs.opengsn.org/#ethereum-gas-station-network-gsn)
9494
- [Infura](https://infura.io/product/ethereum/transactions-itx)
9595
- [Gelato](https://docs.gelato.network/developer-products/gelato-relay-sdk)
@@ -106,23 +106,24 @@ The client that the user interacts with (web browser, mobile apps, etc) never in
106106

107107
For any action that requires blockchain interaction,
108108

109-
- Client requests an EIP712 formatted signature from the user
109+
- Client requests an EIP-712 formatted signature from the user
110110
- 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))
111111
- 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).
112112
- The relayer pays for the gas making the transaction effectively free 🤑
113113

114-
## Integrate Network Agnostic Transactions in your dApp
114+
## Integrate network agnostic transactions in your dApp
115115

116116
- Choose between a custom simple relayer node/biconomy.
117117

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/)
119119

120120
**Steps:**
121121

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
123+
1. Visit [Biconomy's offical docs](https://docs.biconomy.io/dashboard)
124+
2. Navigate and login to the Dashboard
125+
3. Select `Polygon Mumbai` when registering your dapp
126+
2. Copy the`API key` to use for you dapp's frontend
126127
3. And Add function `executeMetaTransaction` in Manage-Api and make sure to enable meta-tx. (Check 'native-metatx' option)
127128

128129
- 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({
163164
params: msgParams
164165
});
165166

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
169-
170-
ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L47](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L47)
171-
172-
```jsx
173-
174-
let data = await web3.eth.abi.encodeFunctionCall({
175-
name: 'getNonce',
176-
type: 'function',
177-
inputs: [{
178-
name: "user",
179-
type: "address"
180-
}]
181-
}, [accounts[0]]);
182-
183-
let _nonce = await web3.eth.call ({
184-
to: token["80001"],
185-
data
186-
});
187-
188-
const dataToSign = getTypedData({
189-
name: token["name"],
190-
version: '1',
191-
salt: '0x0000000000000000000000000000000000000000000000000000000000013881',
192-
verifyingContract: token["80001"],
193-
nonce: parseInt(_nonce),
194-
from: accounts[0],
195-
functionSignature: functionSig
196-
});
197-
const msgParams = [accounts[0], JSON.stringify(dataToSign)];
198-
199-
let sig = await eth.request ({
200-
method: 'eth_signTypedData_v3',
201-
params: msgParams
202-
});
203-
```
204-
205-
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:
224-
225-
```jsx
226-
const response = await request.post(
227-
'https://api.biconomy.io/api/v2/meta-tx/native', {
228-
json: txObj,
229-
},
230-
(error, res, body) => {
231-
if (error) {
232-
console.error(error)
233-
return
234-
}
235-
document.getElementById(el).innerHTML =
236-
`response:`+ JSON.stringify(body)
237-
}
238-
)
239-
```
240-
241-
where the `txObj` should look something like:
242-
243-
```json
244-
{
245-
"to": "0x2395d740789d8C27C139C62d1aF786c77c9a1Ef1",
246-
"apiId": <API ID COPIED FROM THE API PAGE>,
247-
"params": [
248-
"0x2173fdd5427c99357ba0dd5e34c964b08079a695",
249-
"0x2e1a7d4d000000000000000000000000000000000000000000000000000000000000000a",
250-
"0x42da8b5ac3f1c5c35c3eb38d639a780ec973744f11ff75b81bbf916300411602",
251-
"0x32bf1451a3e999b57822bc1a9b8bfdfeb0da59aa330c247e4befafa997a11de9",
252-
"27"
253-
],
254-
"from": "0x2173fdd5427c99357ba0dd5e34c964b08079a695"
255-
}
256-
```
167+
```
257168

258-
- 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
170+
171+
ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L47](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/sign.js#L47)
259172

260-
(ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/server/index.js#L40](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/server/index.js#L40))
261-
262-
```jsx
263-
try {
264-
let tx = await contract.methods.executeMetaTransaction(
265-
txDetails.from, txDetails.fnSig, r, s, v
266-
).send ({
267-
from: user,
268-
gas: 800000
269-
})
270-
req.txHash = tx.transactionHash
271-
} catch (err) {
272-
console.log (err)
273-
next(err)
173+
```jsx
174+
175+
let data = await web3.eth.abi.encodeFunctionCall({
176+
name: 'getNonce',
177+
type: 'function',
178+
inputs: [{
179+
name: "user",
180+
type: "address"
181+
}]
182+
}, [accounts[0]]);
183+
184+
let _nonce = await web3.eth.call ({
185+
to: token["80001"],
186+
data
187+
});
188+
189+
const dataToSign = getTypedData({
190+
name: token["name"],
191+
version: '1',
192+
salt: '0x0000000000000000000000000000000000000000000000000000000000013881',
193+
verifyingContract: token["80001"],
194+
nonce: parseInt(_nonce),
195+
from: accounts[0],
196+
functionSignature: functionSig
197+
});
198+
const msgParams = [accounts[0], JSON.stringify(dataToSign)];
199+
200+
let sig = await eth.request ({
201+
method: 'eth_signTypedData_v3',
202+
params: msgParams
203+
});
204+
```
205+
206+
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+
const response = await request.post(
210+
'http://localhost:3000/exec', {
211+
json: txObj,
212+
},
213+
(error, res, body) => {
214+
if (error) {
215+
console.error(error)
216+
return
274217
}
275-
```
218+
document.getElementById(el).innerHTML =
219+
`response:`+ JSON.stringify(body)
220+
}
221+
)
222+
```
276223

277-
is using biconomy, the client side call looks like:
224+
If using Biconomy, the following should be called:
278225

279-
```jsx
280-
// client/src/App.js
281-
import React from "react";
282-
import Biconomy from "@biconomy/mexa";
226+
```jsx
227+
const response = await request.post(
228+
'https://api.biconomy.io/api/v2/meta-tx/native', {
229+
json: txObj,
230+
},
231+
(error, res, body) => {
232+
if (error) {
233+
console.error(error)
234+
return
235+
}
236+
document.getElementById(el).innerHTML =
237+
`response:`+ JSON.stringify(body)
238+
}
239+
)
240+
```
241+
242+
where the `txObj` should look something like:
243+
244+
```json
245+
{
246+
"to": "0x2395d740789d8C27C139C62d1aF786c77c9a1Ef1",
247+
"apiId": <API ID COPIED FROM THE API PAGE>,
248+
"params": [
249+
"0x2173fdd5427c99357ba0dd5e34c964b08079a695",
250+
"0x2e1a7d4d000000000000000000000000000000000000000000000000000000000000000a",
251+
"0x42da8b5ac3f1c5c35c3eb38d639a780ec973744f11ff75b81bbf916300411602",
252+
"0x32bf1451a3e999b57822bc1a9b8bfdfeb0da59aa330c247e4befafa997a11de9",
253+
"27"
254+
],
255+
"from": "0x2173fdd5427c99357ba0dd5e34c964b08079a695"
256+
}
257+
```
283258

284-
const getWeb3 = new Web3(biconomy);
285-
biconomy
286-
.onEvent(biconomy.READY, () => {
287-
// Initialize your dapp here like getting user accounts etc
288-
console.log("Mexa is Ready");
289-
})
290-
.onEvent(biconomy.ERROR, (error, message) => {
291-
// Handle error while initializing mexa
292-
console.error(error);
293-
});
259+
- If you use the custom API it executes the `executeMetaTransaction` function on the contract:
294260

295-
/**
296-
* use the getWeb3 object to define a contract and calling the function directly
297-
*/
261+
(ref: [https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/server/index.js#L40](https://github.com/angelagilhotra/ETHOnline-Workshop/blob/6b615b8a4ef00553c17729c721572529303c8e1b/2-network-agnostic-transfer/server/index.js#L40))
298262

299-
```
263+
```jsx
264+
try {
265+
let tx = await contract.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+
import React from "react";
283+
import Biconomy from "@biconomy/mexa";
284+
285+
const getWeb3 = new Web3(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+
```
300301

301302
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.
302303

@@ -309,14 +310,14 @@ Contract accounts offer numerous benefits, including:
309310
- **Account security:** Contract accounts enable social recovery and security features such as time-locks and withdraw limits.
310311
- **Atomic multi-operations:** Users can perform multiple operations simultaneously, such as trading in a single click instead of approving and swapping separately.
311312

312-
## Using Account Abstraction on Polygon
313+
## Using account abstraction on Polygon
313314

314315
There are two primary ways users can use account abstraction on Polygon: by sending ERC-4337 transactions or with third party meta transaction services.
315316

316317
### ERC-4337
317318

318319
ERC-4337, also known is EIP-4337, brings account abstraction to the Polygon ecosystem and all EVM-compatible chains.
319320

320-
### Meta Transactions
321+
### Meta transactions
321322

322323
Meta transactions are bespoke third party services for achieving account abstraction.

docs/pos/reference/contracts/genesis-contracts.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ Here you will find a list of contracts deployed on Polygon together with their i
9292

9393
| Contracts | Address |
9494
|-----------------------|--------------------------------------------|
95-
| ChildChain | [0x4f9cd8a945EE035523979D7A120a23999D17D8C0](https://amoy.polygonscan.com/address/0x4f9cd8a945EE035523979D7A120a23999D17D8C0/) |
96-
| EIP1559Burn | [0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9](https://amoy.polygonscan.com/address/0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9/) |
95+
| ChildChain | [0x4f9cd8a945EE035523979D7A120a23999D17D8C0](https://www.oklink.com/amoy/address/0x4f9cd8a945EE035523979D7A120a23999D17D8C0/) |
96+
| EIP1559Burn | [0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9](https://www.oklink.com/amoy/address/0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9/) |
9797
| **Tokens** | |
98-
| MaticToken | [0x0000000000000000000000000000000000001010](https://amoy.polygonscan.com/address/0x0000000000000000000000000000000000001010/) |
99-
| MaticWeth | [0x41Dc3C8eB8368bd9139Cec50434a0C294c8c1102](https://amoy.polygonscan.com/address/0x41Dc3C8eB8368bd9139Cec50434a0C294c8c1102/) |
100-
| RootERC721 | [0x3ADBC484Ff0cFEb657e1A9AF8F3CB16DC0B53e7e](https://amoy.polygonscan.com/address/0x3ADBC484Ff0cFEb657e1A9AF8F3CB16DC0B53e7e/) |
98+
| MaticToken | [0x0000000000000000000000000000000000001010](https://www.oklink.com/amoy/address/0x0000000000000000000000000000000000001010/) |
99+
| MaticWeth | [0x41Dc3C8eB8368bd9139Cec50434a0C294c8c1102](https://www.oklink.com/amoy/address/0x41Dc3C8eB8368bd9139Cec50434a0C294c8c1102/) |
100+
| RootERC721 | [0x3ADBC484Ff0cFEb657e1A9AF8F3CB16DC0B53e7e](https://www.oklink.com/amoy/address/0x3ADBC484Ff0cFEb657e1A9AF8F3CB16DC0B53e7e/) |
101101

102102

103103

0 commit comments

Comments
 (0)