Skip to content

Commit

Permalink
revised structure of API (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLawton authored Apr 11, 2024
1 parent cb58e8f commit 2e0f58a
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 257 deletions.
4 changes: 2 additions & 2 deletions docs/components/Landing/APIsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export const APIsSection = () => (
body="Send and optimize transactions on any chain through our performant Sequence Relayer."
link="/api/relayer"
/>
<Card
{/* <Card
title="Embedded Wallets API"
icon="WalletIcon"
body="Easily onboard web3-native players with a complete Universal Wallet."
link="/"
/>
/> */}
<Card
title="Node Gateway"
icon="NodeGatewayIcon"
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions docs/pages/api/indexer/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ You can see the [full list of supported networks here](/solutions/technical-refe

Here are a few example queries you can make to a blockchain from your dapp, game, or wallet:

- [Fetch all tokens & NFTS in any wallet including all metadata](/api/indexer/fetch-tokens)
- [Fetch the transaction history for any wallet address](/api/indexer/transaction-history)
- [Fetch all unique tokens in a particular ERC20/721/1155 contract, including total supplies](/api/indexer/unique-tokens)
- [Fetch all tokens & NFTS in any wallet including all metadata](/api/indexer/examples/fetch-tokens)
- [Fetch the transaction history for any wallet address](/api/indexer/examples/transaction-history)
- [Fetch all unique tokens in a particular ERC20/721/1155 contract, including total supplies](/api/indexer/examples/unique-tokens)
- [What is the total token supply of an ERC20 token? What is the total token supply of
all the ERC1155 tokens in a particular contract?](/api/indexer/unique-tokens)
- [Fetch the transaction history for any token contract address](/api/indexer/transation-history-token-contract)
all the ERC1155 tokens in a particular contract?](/api/indexer/examples/unique-tokens)
- [Fetch the transaction history for any token contract address](/api/indexer/examples/transation-history-token-contract)

File renamed without changes.
236 changes: 0 additions & 236 deletions docs/pages/api/relayer.mdx

This file was deleted.

61 changes: 61 additions & 0 deletions docs/pages/api/relayer/examples/fetch-fee-options.mdx
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 docs/pages/api/relayer/examples/fetch-transaction-receipts.mdx
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")
```
:::
Loading

0 comments on commit 2e0f58a

Please sign in to comment.