-
Notifications
You must be signed in to change notification settings - Fork 789
Feat/update payment #1946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/update payment #1946
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5744886
added info
soheimam 0d0fc6b
docs(validity): correct transaction behavior
soheimam 4600c1b
added v transactiond docs
soheimam a387bed
Merge branch 'master' into feat/update-payment
soheimam 5fe0212
Merge branch 'master' into feat/update-payment
soheimam 8b91513
updated based on feedback updated agents.md
soheimam 4fba98a
added doc updates
soheimam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
69 changes: 69 additions & 0 deletions
69
docs/specifications/build-transaction/base_sendRawTransactionValidity.mdx
This file contains hidden or 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,69 @@ | ||
| --- | ||
| title: "Validity Transaction RPC" | ||
| sidebarTitle: "Validity Transaction RPC" | ||
| description: "Submit a signed raw transaction with validity predicates." | ||
| --- | ||
|
|
||
| Submits a signed legacy, EIP-2930, or EIP-1559 transaction with predicates that control when Base can include it. EIP-1559 is recommended. | ||
|
|
||
| <Warning> | ||
| This experimental method is currently available on Vibenet. The production API contract is not yet confirmed. | ||
| </Warning> | ||
|
|
||
| ## Parameters | ||
|
|
||
| Pass two parameters. The first is a signed, serialized transaction. The second contains a non-empty `validity` array. | ||
|
|
||
| <RequestExample> | ||
| ```json Request lines wrap expandable | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 1, | ||
| "method": "base_sendRawTransactionValidity", | ||
| "params": [ | ||
| "0x<signed-raw-transaction>", | ||
| { | ||
| "validity": [ | ||
| { | ||
| "type": "storage", | ||
| "params": { | ||
| "address": "0x8ba1f109551bD432803012645Ac136ddd64DBA72", | ||
| "slot": "0x8", | ||
| "mask": "0xff", | ||
| "op": "=", | ||
| "value": "0x2a" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| </RequestExample> | ||
|
|
||
| ## Predicates | ||
|
|
||
| | Type | Parameters | | ||
| | --- | --- | | ||
| | `balance` | `address`, `op`, `value` | | ||
| | `storage` | `address`, `slot`, `op`, `value`, optional `mask` | | ||
| | `block_number` | `op`, `value` | | ||
| | `flashblock_index` | `op`, `value` | | ||
|
|
||
| The supported operators are `<`, `<=`, `=`, `!=`, `>`, and `>=`. Predicate values use `0x`-prefixed hexadecimal strings. The `mask` defaults to all ones. | ||
|
|
||
| ## Returns | ||
|
|
||
| <ResponseField name="result" type="string"> | ||
| The 32-byte hash of the submitted transaction. | ||
| </ResponseField> | ||
|
|
||
| Returning a hash confirms acceptance. It does not confirm inclusion. | ||
|
|
||
| ## Errors | ||
|
|
||
| The method returns JSON-RPC errors. Handle an unavailable method, invalid parameters, and a missing transaction hash. | ||
|
|
||
| Error codes and messages are not yet stable. | ||
|
|
||
| Read [Predicates and Safety](/specifications/build-transaction/predicates-and-safety) for evaluation rules. Read [Troubleshooting](/specifications/build-transaction/troubleshooting) when a transaction is not included. | ||
104 changes: 104 additions & 0 deletions
104
docs/specifications/build-transaction/build-a-validity-transaction.mdx
This file contains hidden or 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,104 @@ | ||
| --- | ||
| title: "Build a Validity Transaction" | ||
| description: "Sign and submit a validity transaction with Viem." | ||
| --- | ||
|
|
||
| This guide uses an EIP-1559 transaction with Viem because it is the recommended transaction type. The API also supports signed legacy and EIP-2930 transactions. | ||
|
|
||
| <Warning> | ||
| Validity Transactions are experimental. `base_sendRawTransactionValidity` is currently available on Vibenet. | ||
| </Warning> | ||
|
|
||
| ## 1. Create Predicates | ||
|
|
||
| Use `balance` or `storage` to wait for account or contract state. Use `block_number` and `flashblock_index` to constrain the candidate position. Every predicate must match. | ||
|
|
||
| ```ts Predicate setup lines wrap expandable | ||
| import type { Address, Hex } from 'viem'; | ||
|
|
||
| const validity = [ | ||
| { | ||
| type: 'balance', | ||
| params: { | ||
| address: '0x8ba1f109551bD432803012645Ac136ddd64DBA72' as Address, | ||
| op: '>=', | ||
| value: '0x1' as Hex, | ||
| }, | ||
| }, | ||
| { | ||
| type: 'storage', | ||
| params: { | ||
| address: '0x8ba1f109551bD432803012645Ac136ddd64DBA72' as Address, | ||
| slot: '0x8' as Hex, | ||
| op: '=', | ||
| value: '0x2a' as Hex, | ||
| }, | ||
| }, | ||
| { | ||
| type: 'block_number', | ||
| params: { op: '<=', value: '0x11a6a1' as Hex }, | ||
| }, | ||
| { | ||
| type: 'flashblock_index', | ||
| params: { op: '<=', value: '0x2' as Hex }, | ||
| }, | ||
| ] as const; | ||
| ``` | ||
|
|
||
| Omit `mask` to compare the full storage word. Use `flashblock_index` to target a position within a Flashblock. | ||
|
|
||
| ## 2. Sign an EIP-1559 Transaction | ||
|
|
||
| Use the sender's next nonce. The signed payload becomes the first RPC parameter. | ||
|
|
||
| ```ts Sign transaction lines wrap expandable | ||
| import { createPublicClient, http, type Chain } from 'viem'; | ||
| import { privateKeyToAccount } from 'viem/accounts'; | ||
|
|
||
| const client = createPublicClient({ chain, transport: http(rpcUrl) }); | ||
| const account = privateKeyToAccount(privateKey); | ||
| const fees = await client.estimateFeesPerGas(); | ||
| const nonce = await client.getTransactionCount({ | ||
| address: account.address, | ||
| blockTag: 'latest', | ||
| }); | ||
|
|
||
| const rawTransaction = await account.signTransaction({ | ||
| chainId: (chain as Chain).id, | ||
| type: 'eip1559', | ||
| nonce, | ||
| to: '0x...' as Address, | ||
| data: '0x...' as Hex, | ||
| value: 0n, | ||
| gas: 100_000n, | ||
| maxFeePerGas: fees.maxFeePerGas, | ||
| maxPriorityFeePerGas: fees.maxPriorityFeePerGas, | ||
| }); | ||
| ``` | ||
|
|
||
| ## 3. Submit the Transaction | ||
|
|
||
| Pass the signed transaction and `validity` as separate parameters. | ||
|
|
||
| ```ts Submit transaction lines wrap expandable | ||
| const response = await fetch(rpcUrl, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ | ||
| jsonrpc: '2.0', | ||
| id: 1, | ||
| method: 'base_sendRawTransactionValidity', | ||
| params: [rawTransaction, { validity }], | ||
| }), | ||
| }); | ||
|
|
||
| const body = await response.json(); | ||
| if (body.error) throw new Error(body.error.message); | ||
| const hash = body.result; | ||
| ``` | ||
|
|
||
| ## 4. Check Inclusion | ||
|
|
||
| The RPC returns a transaction hash. Use [`eth_getTransactionReceipt`](/base-chain/api-reference/ethereum-json-rpc-api/eth_getTransactionReceipt) to check for an onchain receipt. | ||
|
|
||
| For field definitions, see [Validity Transaction RPC](/specifications/build-transaction/base_sendRawTransactionValidity). | ||
22 changes: 22 additions & 0 deletions
22
docs/specifications/build-transaction/fees-ordering-and-lifecycle.mdx
This file contains hidden or 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,22 @@ | ||
| --- | ||
| title: "Fees, Ordering, and Lifecycle" | ||
| description: "Understand fees, expiry, and replacement for validity transactions." | ||
| --- | ||
|
|
||
| ## Fees | ||
|
|
||
| Transactions use the normal fee rules for their type. For EIP-1559 transactions, set `maxFeePerGas` and `maxPriorityFeePerGas` on the signed transaction. | ||
|
|
||
| A transaction that is not included does not pay onchain execution fees. An included transaction pays normal execution fees, even if it reverts. | ||
|
|
||
| ## Ordering | ||
|
|
||
| A transaction competes for inclusion only after every predicate matches. A matching predicate does not reserve block space. | ||
|
|
||
| ## Expiry | ||
|
|
||
| Add a `block_number` predicate with a maximum block to limit a transaction's lifetime. Combine it with `flashblock_index` to tighten the expiry bound to a position within that block's Flashblocks. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we typically capitalize flashblock. |
||
|
|
||
| ## Replacement | ||
|
|
||
| A later transaction with the same sender and nonce can replace a pending transaction. If the RPC returns an underpriced-replacement error, increase the fee fields, sign again, and retry. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.