Repository navigation
docs(giga): add a first-transaction quickstart, live RPC calls, and an Autobahn walkthrough #117
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dbdb540
docs(giga): add a first-transaction quickstart for the Giga testnet
alexander-sei df925a8
docs(giga): add live RPC calls to the Giga testnet pages
alexander-sei 7444c9c
docs(giga): replace the static transaction diagram with a steppable A…
alexander-sei a67e809
docs(snippets): show the JSON-RPC error code in RunSnippet errors
alexander-sei 851bdcd
docs(giga): animate six more Giga diagrams and autoplay them on scroll
alexander-sei fdaa3d3
docs(giga): start the Giga animations sooner and loop them
alexander-sei c35de1c
docs(giga): drop the stale block rate and clarify quickstart key and …
alexander-sei 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| --- | ||
| title: 'Send Your First Transaction on the Sei Giga Testnet' | ||
| sidebarTitle: 'First Transaction' | ||
| description: 'Create a test account, fund it from the faucet, and send and confirm your first transaction on giga-testnet-1 with viem.' | ||
| keywords: ['giga testnet quickstart', 'first transaction', 'giga-testnet-1', 'viem', 'send transaction', 'giga faucet', 'nonce', 'maxPriorityFeePerGas'] | ||
| --- | ||
|
|
||
| This guide takes you from an empty folder to a confirmed transaction on `giga-testnet-1`. You create a test account, fund it from the faucet, and send 0.01 SEI to yourself with [viem](https://viem.sh). It takes about 10 minutes. | ||
|
|
||
| <Note>You need Node.js 20 or later. For the network details and other tools, see [Connect to the Giga testnet](/giga/testnet).</Note> | ||
|
|
||
| <Steps> | ||
| <Step title="Set up a project"> | ||
| ```bash | ||
| mkdir giga-first-tx && cd giga-first-tx | ||
| npm init -y | ||
| npm install viem | ||
| npm install --save-dev tsx | ||
| ``` | ||
| </Step> | ||
| <Step title="Create a test account"> | ||
| Create `create-account.mts`: | ||
|
|
||
| ```typescript title="create-account.mts" | ||
| import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; | ||
|
|
||
| const privateKey = generatePrivateKey(); | ||
| console.log(`Private key: ${privateKey}`); | ||
| console.log(`Address: ${privateKeyToAccount(privateKey).address}`); | ||
| ``` | ||
|
|
||
| Run it, then put the private key that it prints in an environment variable for this terminal session: | ||
|
|
||
| ```bash | ||
| npx tsx create-account.mts | ||
| export PRIVATE_KEY=0x... | ||
| ``` | ||
|
|
||
| <Warning>Use this key only on test networks. Anyone who has the key controls the account.</Warning> | ||
| </Step> | ||
| <Step title="Fund the account"> | ||
| Open the [Giga testnet faucet](https://faucet.giga-testnet-1.platform.sei.io) and paste the address that the script printed. Complete the human verification when the faucet prompts you, then claim. Each claim sends 100 SEI. | ||
| </Step> | ||
| <Step title="Send a transaction and wait for the receipt"> | ||
| Create `send.mts`: | ||
|
|
||
| ```typescript title="send.mts" | ||
| import { createPublicClient, createWalletClient, defineChain, formatEther, formatGwei, http, parseEther } from 'viem'; | ||
| import { privateKeyToAccount } from 'viem/accounts'; | ||
|
|
||
| const seiGigaTestnet = defineChain({ | ||
| id: 1330, | ||
| name: 'Sei Giga Testnet', | ||
| nativeCurrency: { name: 'Sei', symbol: 'SEI', decimals: 18 }, | ||
| rpcUrls: { default: { http: ['https://rpc.giga-testnet-1.platform.sei.io'] } }, | ||
| testnet: true | ||
| }); | ||
|
|
||
| const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); | ||
| // Giga testnet produces several blocks per second, so poll for the receipt often. | ||
| const publicClient = createPublicClient({ chain: seiGigaTestnet, transport: http(), pollingInterval: 250 }); | ||
| const walletClient = createWalletClient({ account, chain: seiGigaTestnet, transport: http() }); | ||
|
|
||
| const balance = await publicClient.getBalance({ address: account.address }); | ||
| console.log(`Balance: ${formatEther(balance)} SEI`); | ||
|
|
||
| const hash = await walletClient.sendTransaction({ to: account.address, value: parseEther('0.01') }); | ||
| console.log(`Sent: ${hash}`); | ||
|
|
||
| const receipt = await publicClient.waitForTransactionReceipt({ hash }); | ||
| console.log(`Status: ${receipt.status} in block ${receipt.blockNumber}`); | ||
| console.log(`Gas used: ${receipt.gasUsed} at ${formatGwei(receipt.effectiveGasPrice)} gwei`); | ||
| ``` | ||
|
|
||
| Run it: | ||
|
|
||
| ```bash | ||
| npx tsx send.mts | ||
| ``` | ||
|
|
||
| viem takes the priority fee from `eth_maxPriorityFeePerGas`, which returns 1 gwei. The base fee on the Giga testnet is always 0, so the priority fee is the whole gas price, and 1 gwei is the minimum that the node accepts. If you set fees yourself, keep `maxPriorityFeePerGas` at 1 gwei or more. | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| You are done when you see a `success` status. Your hash and block number differ: | ||
|
|
||
| ```text | ||
| Balance: 100 SEI | ||
| Sent: 0x8f6c3e0a5b... | ||
| Status: success in block 6974102 | ||
| Gas used: 21000 at 1 gwei | ||
| ``` | ||
|
|
||
| ## Send several transactions in a row | ||
|
|
||
| On the Giga testnet, `eth_getTransactionCount` with the `pending` tag returns the committed nonce. It does not count transactions that have not reached a block yet. To send several transactions before the first one is confirmed, read the nonce once and count up in your client. Send the transactions in nonce order: the node admits each sender's transactions in order and rejects a gap with `bad nonce`. | ||
|
|
||
| ```typescript title="send-several.mts" | ||
| import { createPublicClient, createWalletClient, defineChain, http, parseEther, type Hash } from 'viem'; | ||
| import { privateKeyToAccount } from 'viem/accounts'; | ||
|
|
||
| const seiGigaTestnet = defineChain({ | ||
| id: 1330, | ||
| name: 'Sei Giga Testnet', | ||
| nativeCurrency: { name: 'Sei', symbol: 'SEI', decimals: 18 }, | ||
| rpcUrls: { default: { http: ['https://rpc.giga-testnet-1.platform.sei.io'] } }, | ||
| testnet: true | ||
| }); | ||
|
|
||
| const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); | ||
| const publicClient = createPublicClient({ chain: seiGigaTestnet, transport: http(), pollingInterval: 250 }); | ||
| const walletClient = createWalletClient({ account, chain: seiGigaTestnet, transport: http() }); | ||
|
|
||
| let nonce = await publicClient.getTransactionCount({ address: account.address }); | ||
| const hashes: Hash[] = []; | ||
| for (let i = 0; i < 3; i++) { | ||
| hashes.push(await walletClient.sendTransaction({ to: account.address, value: parseEther('0.001'), nonce: nonce++ })); | ||
| } | ||
|
|
||
| const receipts = await Promise.all(hashes.map((hash) => publicClient.waitForTransactionReceipt({ hash }))); | ||
| for (const receipt of receipts) { | ||
| console.log(`${receipt.status} in block ${receipt.blockNumber}`); | ||
| } | ||
| ``` | ||
|
|
||
| Run it with `npx tsx send-several.mts`. You are done when all three lines say `success`. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| | Error | What to do | | ||
| | --- | --- | | ||
| | `invalid private key, expected hex or 32 bytes, got string` | `PRIVATE_KEY` must be `0x` followed by 64 hex characters. Some wallets export keys without the `0x` prefix, so add it if it's missing | | ||
| | `The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account` | The account has no SEI yet. Claim from the [faucet](https://faucet.giga-testnet-1.platform.sei.io), then run the script again | | ||
| | `ethereum transaction effective gas price is below 1000000000` | Your fee settings are below the 1 gwei minimum. Remove them so that viem estimates them, or set `maxPriorityFeePerGas: parseGwei('1')` | | ||
| | `bad nonce: got N, want M` | A nonce was reused or skipped. Wait for your earlier receipts, then read the nonce again with `getTransactionCount` | | ||
| | `ethereum transaction chain ID does not match 1330` | The transaction was signed for another chain. Use chain ID `1330` | | ||
|
|
||
| For every RPC limit and its error, see [RPC limits](/giga/rpc-limits). | ||
|
|
||
| ## Next steps | ||
|
|
||
| <CardGroup cols={2}> | ||
| <Card horizontal title="How the Giga testnet differs" icon="code-compare" href="/giga/testnet#how-the-giga-testnet-differs-from-sei-testnet"> | ||
| Fees, precompiles, preinstalled contracts, and block fields that differ from Sei Testnet. | ||
| </Card> | ||
| <Card horizontal title="RPC limits" icon="gauge-high" href="/giga/rpc-limits"> | ||
| Every cap the Giga testnet RPC enforces, and the error that each one returns. | ||
| </Card> | ||
| <Card horizontal title="Deploy a contract" icon="file-code" href="/giga/testnet#configure-your-tools"> | ||
| Hardhat and Foundry settings for the Giga testnet. | ||
| </Card> | ||
| <Card horizontal title="Developer guide" icon="code" href="/giga/developers"> | ||
| Finality, fees, and contract patterns that make the most of Giga's parallel execution. | ||
| </Card> | ||
| </CardGroup> |
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
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.