-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
cb58e8f
commit 2e0f58a
Showing
15 changed files
with
271 additions
and
257 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
## Fetching fee options | ||
|
||
:::warning | ||
Fee selection is only necessary if you aren't already using Sequence Builder's gas sponsorship capabilities! | ||
Create your project in Sequence Builder for ease of development today! | ||
::: | ||
|
||
|
||
:::code-group | ||
```typescript [TypeScript] | ||
import { Session } from '@0xsequence/auth' | ||
import { ethers } from 'ethers' | ||
|
||
const config = { | ||
mnemonic: 'YOUR MNEMONIC', | ||
projectAccessKey: 'YOUR PROJECT ACCESS KEY', | ||
chainId: ChainId.YOUR_CHAIN_ID // e.g. ChainId.MAINNET, ChainId.POLYGON, etc. | ||
} | ||
|
||
const signer = ethers.Wallet.fromMnemonic(config.mnemonic) | ||
|
||
const session = await Session.singleSigner({ signer, projectAccessKey: config.projectAccessKey }) | ||
|
||
const account = session.account.getSigner(config.chainId, { | ||
async selectFee(_transactions, options) { | ||
// This callback is called with the list of candidate fee options. | ||
|
||
console.log('Fee options:', JSON.stringify(options, undefined, 2)) | ||
|
||
// Select the USDC fee option. | ||
return options.find(option => option.token.symbol === 'USDC') | ||
} | ||
}) | ||
``` | ||
|
||
```go [Go] | ||
mnemonic := "YOUR MNEMONIC" | ||
projectAccessKey := "YOUR PROJECT ACCESS KEY" | ||
rpcURL := fmt.Sprintf("https://nodes.sequence.app/YOUR-NETWORK/%v", projectAccessKey) | ||
relayerURL := "https://YOUR-NETWORK-relayer.sequence.app" | ||
|
||
signer, _ := ethwallet.NewWalletFromMnemonic(mnemonic) | ||
|
||
wallet, _ := sequence.NewWalletSingleOwner(signer) | ||
|
||
provider, _ := ethrpc.NewProvider(rpcURL) | ||
wallet.SetProvider(provider) | ||
|
||
relayer, _ := relayer.NewRpcRelayer(relayerURL, projectAccessKey, provider, nil) | ||
wallet.SetRelayer(relayer) | ||
|
||
transactions := sequence.Transactions{ | ||
&sequence.Transaction{ | ||
To: common.HexToAddress("0x468E8e29F6cfb0F6b7ff10ec6A1AB516ec849c04"), | ||
Value: big.NewInt(1000000000000000000), | ||
}, | ||
} | ||
|
||
options, quote, _ := wallet.FeeOptions(ctx, transactions) | ||
``` | ||
::: |
32 changes: 32 additions & 0 deletions
32
docs/pages/api/relayer/examples/fetch-transaction-receipts.mdx
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,32 @@ | ||
## Fetching transaction receipts | ||
|
||
To fetch a transaction receipt for an arbitrary transaction that was dispatched via the relayer, call the `/GetMetaTxnReceipt` endpoint. | ||
The `metaTxID` is the `txnHash` from the response of the `/SendMetaTxn` endpoint. | ||
|
||
:::code-group | ||
```sh [curl] | ||
curl -s -X POST -H 'Content-Type: application/json' \ | ||
-d '{"metaTxID":"462de2756e45c93698b89ada5ba4a3c9d1bfb9fb354ad2e7f36f1a9fefbc550b"}' \ | ||
https://polygon-relayer.sequence.app/rpc/Relayer/GetMetaTxnReceipt | jq | ||
|
||
{ | ||
"receipt": { | ||
"id": "462de2756e45c93698b89ada5ba4a3c9d1bfb9fb354ad2e7f36f1a9fefbc550b", | ||
"status": "SUCCEEDED", | ||
"revertReason": null, | ||
"index": 0, | ||
"logs": [] | ||
} | ||
} | ||
|
||
... | ||
``` | ||
|
||
```typescript [TypeScript] | ||
const { receipt } = await session.account.relayer(config.chainId).wait('462de2756e45c93698b89ada5ba4a3c9d1bfb9fb354ad2e7f36f1a9fefbc550b') | ||
``` | ||
|
||
```go [Go] | ||
status, receipt, _ := relayer.Wait(ctx, "462de2756e45c93698b89ada5ba4a3c9d1bfb9fb354ad2e7f36f1a9fefbc550b") | ||
``` | ||
::: |
Oops, something went wrong.