From a8f179b65f96e6b3ddaa83de5e92f791e3587a10 Mon Sep 17 00:00:00 2001 From: Joan E <153745173+joaniefromtheblock@users.noreply.github.com> Date: Tue, 16 Jul 2024 01:00:13 +0000 Subject: [PATCH] apply review suggestions --- services/get-started/infura.md | 4 +- services/how-to/make-batch-requests.md | 65 +++-- .../_eth_getblockbynumber-response.mdx | 1 - .../_partials/_eth_getstorageat-response.mdx | 14 +- .../reference/avalanche-c-chain/quickstart.md | 8 +- services/reference/base/quickstart.md | 8 +- services/reference/blast/quickstart.md | 8 +- services/reference/celo/quickstart.md | 8 +- .../ethereum/json-rpc-methods/index.md | 4 +- services/reference/ethereum/quickstart.md | 8 +- .../ipfs/http-api-methods/dag_resolve.md | 8 +- .../ipfs/http-api-methods/version.md | 16 +- services/reference/ipfs/quickstart.md | 118 ++++----- .../_eth_accounts-request.mdx | 6 +- .../_eth_blocknumber-request.mdx | 6 +- .../json-rpc-methods/_eth_chainid-request.mdx | 9 +- .../_eth_estimategas-request.mdx | 8 +- .../_eth_getblockbynumber-request.mdx | 4 +- ...getblocktransactioncountbyhash-request.mdx | 4 +- ...tblocktransactioncountbynumber-request.mdx | 4 +- .../_eth_getstorageat-request.mdx | 4 +- .../debug/debug_traceblockbyhash.md | 9 +- .../debug/debug_traceblockbynumber.md | 64 +++-- .../debug/debug_tracetransaction.md | 9 +- .../json-rpc-methods/linea_estimategas.mdx | 8 +- services/reference/linea/quickstart.md | 6 +- .../debug/debug_storagerangeat.md | 2 +- .../debug/debug_traceblock.md | 2 +- .../debug/debug_traceblockbyhash.md | 2 +- .../debug/debug_traceblockbynumber.md | 3 +- .../json-rpc-methods/debug/debug_tracecall.md | 2 +- .../debug/debug_tracetransaction.md | 2 +- services/reference/mantle/quickstart.md | 2 +- .../_eth_estimategas-request.mdx | 6 +- .../_eth_getblockbyhash-request.mdx | 8 +- services/reference/palm/quickstart.md | 6 +- services/reference/polygon-pos/quickstart.md | 14 +- services/reference/starknet/quickstart.md | 10 +- .../json-rpc-methods/zks_getmaincontract.mdx | 2 +- ...retrieve-the-balance-of-an-erc-20-token.md | 4 +- .../send-a-transaction-ethers.md | 52 ++-- .../send-a-transaction-go.md | 144 ++++++----- .../send-a-transaction-py.md | 34 +-- ...thers.js-infuraprovider-or-web3provider.md | 6 +- .../ethereum/send-a-transaction/use-rust.md | 236 ++++++++++++------ .../subscribe-to-pending-transactions.md | 14 +- ...ck-erc-721-and-erc-1155-token-transfers.md | 8 +- 47 files changed, 518 insertions(+), 452 deletions(-) diff --git a/services/get-started/infura.md b/services/get-started/infura.md index f91c295aca7..121d6936669 100644 --- a/services/get-started/infura.md +++ b/services/get-started/infura.md @@ -139,8 +139,8 @@ Body: "jsonrpc": "2.0", "method": "eth_getBalance", "params": [ - "0x00000000219ab540356cBB839Cbe05303d7705Fa", - "latest" + "0x00000000219ab540356cBB839Cbe05303d7705Fa", + "latest" ], "id": 1 } diff --git a/services/how-to/make-batch-requests.md b/services/how-to/make-batch-requests.md index fbed1950361..e2f13ff1797 100644 --- a/services/how-to/make-batch-requests.md +++ b/services/how-to/make-batch-requests.md @@ -24,38 +24,37 @@ Example batch request (containing 30 requests plus the batch request itself): ```json curl --request POST \ --url https://mainnet.infura.io/v3/ \ - --header "Content-Type: application/json" + --header "Content-Type: application/json" \ --data '[ - {"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 2, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 3, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 4, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 5, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 6, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 7, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 8, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 9, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 10, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 11, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 12, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 13, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 14, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 15, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 16, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 17, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 18, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 19, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 20, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 21, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 22, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 23, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 24, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 25, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 26, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 27, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 28, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 29, "method": "eth_blockNumber", "params": []}, - {"jsonrpc": "2.0", "id": 30, "method": "eth_accounts", "params": []} -]' - + {"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 2, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 3, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 4, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 5, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 6, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 7, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 8, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 9, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 10, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 11, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 12, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 13, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 14, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 15, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 16, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 17, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 18, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 19, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 20, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 21, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 22, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 23, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 24, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 25, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 26, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 27, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 28, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 29, "method": "eth_blockNumber", "params": []}, + {"jsonrpc": "2.0", "id": 30, "method": "eth_accounts", "params": []} + ]' ``` diff --git a/services/reference/_partials/_eth_getblockbynumber-response.mdx b/services/reference/_partials/_eth_getblockbynumber-response.mdx index 4de1c57a28a..d3517720e33 100644 --- a/services/reference/_partials/_eth_getblockbynumber-response.mdx +++ b/services/reference/_partials/_eth_getblockbynumber-response.mdx @@ -5,7 +5,6 @@ import TabItem from "@theme/TabItem" ```js -{ { "jsonrpc": "2.0", "id": 1, diff --git a/services/reference/_partials/_eth_getstorageat-response.mdx b/services/reference/_partials/_eth_getstorageat-response.mdx index d1255a3a9a8..7a606d3f85c 100644 --- a/services/reference/_partials/_eth_getstorageat-response.mdx +++ b/services/reference/_partials/_eth_getstorageat-response.mdx @@ -17,17 +17,17 @@ import TabItem from "@theme/TabItem" ## Additional notes -Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at `0x295a70b2de5e3953354a6a8344e616ed314d7251` by address `0x391694e7e0b0cce554cb130d723a9d27458f9298`, +Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at `0x295a70b2de5e3953354a6a8344e616ed314d7251` by address `0x391694e7e0b0cce554cb130d723a9d27458f9298`: ```solidity contract Storage { - uint pos0; - mapping(address => uint) pos1; + uint pos0; + mapping(address => uint) pos1; - function Storage() { - pos0 = 1234; - pos1[msg.sender] = 5678; - } + function Storage() public { + pos0 = 1234; + pos1[msg.sender] = 5678; + } } ``` diff --git a/services/reference/avalanche-c-chain/quickstart.md b/services/reference/avalanche-c-chain/quickstart.md index c5e32f546fd..d6e73b79c63 100644 --- a/services/reference/avalanche-c-chain/quickstart.md +++ b/services/reference/avalanche-c-chain/quickstart.md @@ -165,10 +165,10 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://avalanche-mainnet.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/base/quickstart.md b/services/reference/base/quickstart.md index 32c6c97f0f9..d7ca3a92a9d 100644 --- a/services/reference/base/quickstart.md +++ b/services/reference/base/quickstart.md @@ -166,10 +166,10 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://base-sepolia.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/blast/quickstart.md b/services/reference/blast/quickstart.md index 73c6e57151e..c1adae25843 100644 --- a/services/reference/blast/quickstart.md +++ b/services/reference/blast/quickstart.md @@ -166,10 +166,10 @@ In these examples, you'll use [NPM](https://docs.npmjs.com/downloading-and-insta url = "https://blast-mainnet.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/celo/quickstart.md b/services/reference/celo/quickstart.md index 384c59f82a4..b08617070dd 100644 --- a/services/reference/celo/quickstart.md +++ b/services/reference/celo/quickstart.md @@ -166,10 +166,10 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://celo-mainnet.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/ethereum/json-rpc-methods/index.md b/services/reference/ethereum/json-rpc-methods/index.md index a67f07d89fb..fd84efd7a61 100644 --- a/services/reference/ethereum/json-rpc-methods/index.md +++ b/services/reference/ethereum/json-rpc-methods/index.md @@ -50,8 +50,8 @@ Example error response: "id": 1337 "jsonrpc": "2.0", "error": { - "code": -32003, - "message": "Transaction rejected" + "code": -32003, + "message": "Transaction rejected" } } ``` diff --git a/services/reference/ethereum/quickstart.md b/services/reference/ethereum/quickstart.md index 8f28f5a1589..0796315a157 100644 --- a/services/reference/ethereum/quickstart.md +++ b/services/reference/ethereum/quickstart.md @@ -211,10 +211,10 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://mainnet.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {'content-type': 'application/json'} diff --git a/services/reference/ipfs/http-api-methods/dag_resolve.md b/services/reference/ipfs/http-api-methods/dag_resolve.md index 16fc3f3ce62..2554c626a0c 100644 --- a/services/reference/ipfs/http-api-methods/dag_resolve.md +++ b/services/reference/ipfs/http-api-methods/dag_resolve.md @@ -32,7 +32,7 @@ curl "https://ipfs.infura.io:5001/api/v0/dag/resolve?arg=QmZtmD2qt6fJot32nabSP3C #### REQUEST PARAMS -- `arg` _\[Required]_ - The IPFS object hash; the path to resolve. +- `arg` _[Required]_ - The IPFS object hash; the path to resolve. ### RESPONSE @@ -42,10 +42,10 @@ On success, the call to this endpoint will return with 200 and the following bod ```js { - Cid: { - /: "QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy" + "Cid": { + "/": "QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy" }, - RemPath: "" + "RemPath": "" } ``` diff --git a/services/reference/ipfs/http-api-methods/version.md b/services/reference/ipfs/http-api-methods/version.md index 5a006f092c6..7cfa61825ed 100644 --- a/services/reference/ipfs/http-api-methods/version.md +++ b/services/reference/ipfs/http-api-methods/version.md @@ -14,8 +14,8 @@ Show IPFS version information. ```bash curl "https://ipfs.infura.io:5001/api/v0/version?number=&commit=&repo=&all=" \ - -X POST \ - -u ":" + -X POST \ + -u ":" ``` @@ -23,8 +23,8 @@ curl "https://ipfs.infura.io:5001/api/v0/version?number=&commit=&r ```bash curl "https://ipfs.infura.io:5001/api/v0/version" \ - -X POST \ - -u "PROJECT_ID:PROJECT_SECRET" + -X POST \ + -u "PROJECT_ID:PROJECT_SECRET" ``` @@ -32,10 +32,10 @@ curl "https://ipfs.infura.io:5001/api/v0/version" \ #### REQUEST PARAMS -- `number` _\[Optional]_ - Only show the version number. -- `commit` _\[Optional]_ - Show the commit hash. -- `repo` _\[Optional] -_ Show repo version. -- `all` _\[Optional]_ - Show all version information. +- `number` _[Optional]_ - Only show the version number. +- `commit` _[Optional]_ - Show the commit hash. +- `repo` _[Optional]_ - Show repo version. +- `all` _[Optional]_ - Show all version information. ### RESPONSE diff --git a/services/reference/ipfs/quickstart.md b/services/reference/ipfs/quickstart.md index d3ede0effc6..730c7f580f4 100644 --- a/services/reference/ipfs/quickstart.md +++ b/services/reference/ipfs/quickstart.md @@ -96,7 +96,7 @@ endpoint = "https://ipfs.infura.io:5001" ### CREATE AN ARRAY OF TEST FILES ### files = { - "file": "myNFT.png" + "file": "myNFT.png" } ### ADD FILE TO IPFS AND SAVE THE HASH ### @@ -107,7 +107,7 @@ print(hash ### READ FILE WITH HASH ### params = { - "arg": hash + "arg": hash } response2 = requests.post(endpoint + "/api/v0/cat", params=params, auth=(projectId, projectSecret)) print(response2) @@ -179,49 +179,49 @@ CID(QmeGAVddnBSnKc1DLE7DLV9uuTqo5F7QbaveTjr45JUdQn) package main import ( - "fmt" - "net/http" - "os" - "strings" + "fmt" + "net/http" + "os" + "strings" - ipfsApi "github.com/ipfs/go-ipfs-api" // v0.2.0 + ipfsApi "github.com/ipfs/go-ipfs-api" // v0.2.0 ) func main() { - projectId := "" - projectSecret := "" + projectId := "" + projectSecret := "" - shell := ipfsApi.NewShellWithClient("https://ipfs.infura.io:5001", NewClient(projectId, projectSecret)) - cid, err := shell.Add(strings.NewReader("Infura IPFS - Getting started demo.")) - if err != nil { - fmt.Println(err) - os.Exit(1) - } + shell := ipfsApi.NewShellWithClient("https://ipfs.infura.io:5001", NewClient(projectId, projectSecret)) + cid, err := shell.Add(strings.NewReader("Infura IPFS - Getting started demo.")) + if err != nil { + fmt.Println(err) + os.Exit(1) + } - fmt.Printf("Data successfully stored in IPFS: %v\n", cid) + fmt.Printf("Data successfully stored in IPFS: %v\n", cid) } -// NewClient creates an http.Client that automatically perform basic auth on each request. +// NewClient creates an http.Client that automatically performs basic auth on each request. func NewClient(projectId, projectSecret string) *http.Client { - return &http.Client{ - Transport: authTransport{ - RoundTripper: http.DefaultTransport, - ProjectId: projectId, - ProjectSecret: projectSecret, - }, - } + return &http.Client{ + Transport: authTransport{ + RoundTripper: http.DefaultTransport, + ProjectId: projectId, + ProjectSecret: projectSecret, + }, + } } // authTransport decorates each request with a basic auth header. type authTransport struct { - http.RoundTripper - ProjectId string - ProjectSecret string + http.RoundTripper + ProjectId string + ProjectSecret string } func (t authTransport) RoundTrip(r *http.Request) (*http.Response, error) { - r.SetBasicAuth(t.ProjectId, t.ProjectSecret) - return t.RoundTripper.RoundTrip(r) + r.SetBasicAuth(t.ProjectId, t.ProjectSecret) + return t.RoundTripper.RoundTrip(r) } ``` @@ -244,42 +244,42 @@ CID(QmeGAVddnBSnKc1DLE7DLV9uuTqo5F7QbaveTjr45JUdQn) package main import ( - "context" - "encoding/base64" - "fmt" - "net/http" - "os" - "strings" - - ipfsFiles "github.com/ipfs/go-ipfs-files" // v0.0.8 - ipfsApi "github.com/ipfs/go-ipfs-http-client" // v0.1.0 + "context" + "encoding/base64" + "fmt" + "net/http" + "os" + "strings" + + ipfsFiles "github.com/ipfs/go-ipfs-files" // v0.0.8 + ipfsApi "github.com/ipfs/go-ipfs-http-client" // v0.1.0 ) func main() { - projectId := "" - projectSecret := "" - - httpClient := &http.Client{} - httpApi, err := ipfsApi.NewURLApiWithClient("https://ipfs.infura.io:5001", httpClient) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - httpApi.Headers.Add("Authorization", "Basic " + basicAuth(projectId, projectSecret)) - - content := strings.NewReader("Infura IPFS - Getting started demo.") - p, err := httpApi.Unixfs().Add(context.Background(), ipfsFiles.NewReaderFile(content)) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - fmt.Printf("Data successfully stored in IPFS: %v\n", p.Cid().String()) + projectId := "" + projectSecret := "" + + httpClient := &http.Client{} + httpApi, err := ipfsApi.NewURLApiWithClient("https://ipfs.infura.io:5001", httpClient) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + httpApi.Headers.Add("Authorization", "Basic " + basicAuth(projectId, projectSecret)) + + content := strings.NewReader("Infura IPFS - Getting started demo.") + p, err := httpApi.Unixfs().Add(context.Background(), ipfsFiles.NewReaderFile(content)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Printf("Data successfully stored in IPFS: %v\n", p.Cid().String()) } func basicAuth(projectId, projectSecret string) string { - auth := projectId + ":" + projectSecret - return base64.StdEncoding.EncodeToString([]byte(auth)) + auth := projectId + ":" + projectSecret + return base64.StdEncoding.EncodeToString([]byte(auth)) } ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_accounts-request.mdx b/services/reference/linea/json-rpc-methods/_eth_accounts-request.mdx index 56512713289..ad06979cbfe 100644 --- a/services/reference/linea/json-rpc-methods/_eth_accounts-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_accounts-request.mdx @@ -6,9 +6,9 @@ import TabItem from "@theme/TabItem" ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_accounts", "params": [], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_accounts", "params": [], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_blocknumber-request.mdx b/services/reference/linea/json-rpc-methods/_eth_blocknumber-request.mdx index 16e816e0d28..283e8e90cd9 100644 --- a/services/reference/linea/json-rpc-methods/_eth_blocknumber-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_blocknumber-request.mdx @@ -6,9 +6,9 @@ import TabItem from "@theme/TabItem" ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_chainid-request.mdx b/services/reference/linea/json-rpc-methods/_eth_chainid-request.mdx index 7d79cb7c9b2..2db99ba6fad 100644 --- a/services/reference/linea/json-rpc-methods/_eth_chainid-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_chainid-request.mdx @@ -6,18 +6,17 @@ import TabItem from "@theme/TabItem" ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_chainId","params": [],"id":1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_chainId","params": [],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}' ``` - diff --git a/services/reference/linea/json-rpc-methods/_eth_estimategas-request.mdx b/services/reference/linea/json-rpc-methods/_eth_estimategas-request.mdx index 898aaf4bc5c..458e0e04688 100644 --- a/services/reference/linea/json-rpc-methods/_eth_estimategas-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_estimategas-request.mdx @@ -6,16 +6,16 @@ import TabItem from "@theme/TabItem" ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","value": "0x9184e72a"}],"id":1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_estimateGas", "params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC", "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "value": "0x9184e72a"}], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","value": "0x9184e72a"}],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_estimateGas", "params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC", "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "value": "0x9184e72a"}], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_getblockbynumber-request.mdx b/services/reference/linea/json-rpc-methods/_eth_getblockbynumber-request.mdx index 792e94eeba7..d96a0c9140c 100644 --- a/services/reference/linea/json-rpc-methods/_eth_getblockbynumber-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_getblockbynumber-request.mdx @@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem" curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x5BAD55",false],"id":1}' + -d '{"jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x5BAD55", false], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params": ["0x5BAD55",false],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x5BAD55", false], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbyhash-request.mdx b/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbyhash-request.mdx index 59523778df5..a63e918c999 100644 --- a/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbyhash-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbyhash-request.mdx @@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem" curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"],"id":1}' + -d '{"jsonrpc": "2.0", "method": "eth_getBlockTransactionCountByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getBlockTransactionCountByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbynumber-request.mdx b/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbynumber-request.mdx index e2786881f7f..9369d15bc30 100644 --- a/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbynumber-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_getblocktransactioncountbynumber-request.mdx @@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem" curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params": ["latest"],"id":1}' + -d '{"jsonrpc": "2.0", "method": "eth_getBlockTransactionCountByNumber", "params": ["latest"], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params": ["latest"],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getBlockTransactionCountByNumber", "params": ["latest"], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/_eth_getstorageat-request.mdx b/services/reference/linea/json-rpc-methods/_eth_getstorageat-request.mdx index f30399107f5..abe041fa6bd 100644 --- a/services/reference/linea/json-rpc-methods/_eth_getstorageat-request.mdx +++ b/services/reference/linea/json-rpc-methods/_eth_getstorageat-request.mdx @@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem" curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"eth_getStorageAt","params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "0x65a8db"],"id":1}' + -d '{"jsonrpc": "2.0", "method": "eth_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "0x65a8db"], "id": 1}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"eth_getStorageAt","params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "0x65a8db"],"id":1}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "0x65a8db"], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/debug/debug_traceblockbyhash.md b/services/reference/linea/json-rpc-methods/debug/debug_traceblockbyhash.md index 165c850d508..266fbca91fa 100644 --- a/services/reference/linea/json-rpc-methods/debug/debug_traceblockbyhash.md +++ b/services/reference/linea/json-rpc-methods/debug/debug_traceblockbyhash.md @@ -33,17 +33,16 @@ Depending on the specified tracer type, returns a [`callTracer`](../debug/index. ```bash curl https://linea-goerli.infura.io/v3/ \ --X POST \ --H "Content-Type: application/json" \ --d '{"method":"debug_traceBlockByHash","params":["0xcc4e47e5f5e82c12ccd511e97f6994b4c4f95808778323ed5cf0a56640b0a815", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "debug_traceBlockByHash", "params": ["0xcc4e47e5f5e82c12ccd511e97f6994b4c4f95808778323ed5cf0a56640b0a815", {"tracer": "callTracer"}], "id": 1}' ``` ```bash -wscat -c wss://linea-goerli.infura.io/ws/v3/ \ --x '{"method":"debug_traceBlockByHash","params":["0xcc4e47e5f5e82c12ccd511e97f6994b4c4f95808778323ed5cf0a56640b0a815", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' +wscat -c wss://linea-goerli.infura.io/ws/v3/ -x '{"jsonrpc": "2.0", "method": "debug_traceBlockByHash","params": ["0xcc4e47e5f5e82c12ccd511e97f6994b4c4f95808778323ed5cf0a56640b0a815", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/debug/debug_traceblockbynumber.md b/services/reference/linea/json-rpc-methods/debug/debug_traceblockbynumber.md index d83a6ea2278..a4dc9c00824 100644 --- a/services/reference/linea/json-rpc-methods/debug/debug_traceblockbynumber.md +++ b/services/reference/linea/json-rpc-methods/debug/debug_traceblockbynumber.md @@ -34,18 +34,16 @@ Depending on the specified tracer type, returns a [`callTracer`](index.md##callt ```bash curl https://linea-mainnet.infura.io/v3/ \ --X POST \ --H "Content-Type: application/json" \ --d '{"method":"debug_traceBlockByNumber","params":["0x4d0c", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' - + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "debug_traceBlockByNumber", "params": ["0x4d0c", {"tracer": "callTracer"}], "id": 1}' ``` ```bash -wscat -c wss://linea-goerli.infura.io/ws/v3/ \ --x '{"method":"debug_traceBlockByNumber","params":["0x4d0c", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' +wscat -c wss://linea-goerli.infura.io/ws/v3/ -x '{"jsonrpc": "2.0", "method": "debug_traceBlockByNumber", "params": ["0x4d0c", {"tracer": "callTracer"}], "id": 1}' ``` @@ -55,32 +53,32 @@ wscat -c wss://linea-goerli.infura.io/ws/v3/ \ ```json { - "jsonrpc": "2.0", - "id": 1, - "result": [ - { - "result": { - "from": "0xa5ba45f484bc67fe293cf01f7d92d5ba3514dd42", - "gas": "0x5208", - "gasUsed": "0x5208", - "input": "0x", - "to": "0x45a318273749d6eb00f5f6ca3bc7cd3de26d642a", - "type": "CALL", - "value": "0x2ca186f5fda8004" - } - }, - { - "result": { - "from": "0x25f2650cc9e8ad863bf5da6a7598e24271574e29", - "gas": "0xfe0e", - "gasUsed": "0xafee", - "input": "0xd0e30db0", - "to": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", - "type": "CALL", - "value": "0x2386f26fc10000" - } - }, - ... - ] + "jsonrpc": "2.0", + "id": 1, + "result": [ + { + "result": { + "from": "0xa5ba45f484bc67fe293cf01f7d92d5ba3514dd42", + "gas": "0x5208", + "gasUsed": "0x5208", + "input": "0x", + "to": "0x45a318273749d6eb00f5f6ca3bc7cd3de26d642a", + "type": "CALL", + "value": "0x2ca186f5fda8004" + } + }, + { + "result": { + "from": "0x25f2650cc9e8ad863bf5da6a7598e24271574e29", + "gas": "0xfe0e", + "gasUsed": "0xafee", + "input": "0xd0e30db0", + "to": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", + "type": "CALL", + "value": "0x2386f26fc10000" + } + } + ... + ] } ``` diff --git a/services/reference/linea/json-rpc-methods/debug/debug_tracetransaction.md b/services/reference/linea/json-rpc-methods/debug/debug_tracetransaction.md index 3f08e3f47cf..4a9dbaa87d3 100644 --- a/services/reference/linea/json-rpc-methods/debug/debug_tracetransaction.md +++ b/services/reference/linea/json-rpc-methods/debug/debug_tracetransaction.md @@ -35,17 +35,16 @@ Depending on the specified tracer type, returns a [`callTracer`](index.md##callt ```bash curl https://linea-mainnet.infura.io/v3/ \ --X POST \ --H "Content-Type: application/json" \ --d '{"method":"debug_traceTransaction","params":["0x5d3faa9b9605a8fb04d989a79bfe6d3b708bdcfc66048d2fe18ed2dda4a8297c", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "debug_traceTransaction", "params": ["0x5d3faa9b9605a8fb04d989a79bfe6d3b708bdcfc66048d2fe18ed2dda4a8297c", {"tracer": "callTracer"}], "id": 1}' ``` ```bash -wscat -c wss://linea-goerli.infura.io/ws/v3/ \ --x '{"method":"debug_traceTransaction","params":["0x5d3faa9b9605a8fb04d989a79bfe6d3b708bdcfc66048d2fe18ed2dda4a8297c", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' +wscat -c wss://linea-goerli.infura.io/ws/v3/ -x '{"jsonrpc": "2.0", "method": "debug_traceTransaction", "params": ["0x5d3faa9b9605a8fb04d989a79bfe6d3b708bdcfc66048d2fe18ed2dda4a8297c", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/linea/json-rpc-methods/linea_estimategas.mdx b/services/reference/linea/json-rpc-methods/linea_estimategas.mdx index 075da53b45a..9ca76f53f4a 100644 --- a/services/reference/linea/json-rpc-methods/linea_estimategas.mdx +++ b/services/reference/linea/json-rpc-methods/linea_estimategas.mdx @@ -60,16 +60,16 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"linea_estimateGas","params":[{"from":"0x42c27251C710864Cf76f1b9918Ace3E585e6E21b","value":"0x1","gasPrice":"0x100000000","gas":"0x21000"}],"id":53}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "linea_estimateGas", "params": [{"from": "0x42c27251C710864Cf76f1b9918Ace3E585e6E21b", "value": "0x1", "gasPrice": "0x100000000", "gas": "0x21000"}], "id": 53}' ``` ```bash -wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc":"2.0","method":"linea_estimateGas","params":[{"from":"0x42c27251C710864Cf76f1b9918Ace3E585e6E21b","value":"0x1","gasPrice":"0x100000000","gas":"0x21000"}],"id":53}' +wscat -c wss://linea-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "linea_estimateGas", "params": [{"from": "0x42c27251C710864Cf76f1b9918Ace3E585e6E21b", "value": "0x1", "gasPrice": "0x100000000", "gas": "0x21000"}], "id": 53}' ``` diff --git a/services/reference/linea/quickstart.md b/services/reference/linea/quickstart.md index 2cea3802608..813b13115b9 100644 --- a/services/reference/linea/quickstart.md +++ b/services/reference/linea/quickstart.md @@ -25,9 +25,9 @@ Run the following command in your terminal, replacing `YOUR-API-KEY` with your a ```bash curl https://linea-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' ``` ### Node (JavaScript) diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_storagerangeat.md b/services/reference/mantle/json-rpc-methods/debug/debug_storagerangeat.md index 521abfc3f47..3b1b51c2801 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_storagerangeat.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_storagerangeat.md @@ -34,7 +34,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"debug_storageRangeAt","params":["0x7aaff18735842066baee6a2eb53961a69e67f5e012072c81c05a0fd793069a6c",0,"0x371c7ec6D8039ff7933a2AA28EB827Ffe1F52f07","0x0000000000000000000000000000000000000000000000000000000000000000",1], "id":1}' + -d '{"jsonrpc": "2.0", "method": "debug_storageRangeAt", "params": ["0x7aaff18735842066baee6a2eb53961a69e67f5e012072c81c05a0fd793069a6c", 0, "0x371c7ec6D8039ff7933a2AA28EB827Ffe1F52f07", "0x0000000000000000000000000000000000000000000000000000000000000000", 1], "id": 1}' ``` diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_traceblock.md b/services/reference/mantle/json-rpc-methods/debug/debug_traceblock.md index a4a74c89b7a..de9c3860f3c 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_traceblock.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_traceblock.md @@ -37,7 +37,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0","method":"debug_traceBlock","params":["0xf90277f90208a05a41d0e66b4120775176c09fcf39e7c0520517a13d2b57b18d33d342df038bfca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e6a7a1d47ff21b6321162aea7c6cb457d5476bcaa00e0df2706b0a4fb8bd08c9246d472abbe850af446405d9eba1db41db18b4a169a04513310fcb9f6f616972a3b948dc5d547f280849a87ebb5af0191f98b87be598a0fe2bf2a941abf41d72637e5b91750332a30283efd40c424dc522b77e6f0ed8c4b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000860153886c1bbd82b44382520b8252088455c426598b657468706f6f6c2e6f7267a0b48c515a9dde8d346c3337ea520aa995a4738bb595495506125449c1149d6cf488ba4f8ecd18aab215f869f86780862d79883d2000825208945df9b87991262f6ba471f09758cde1c0fc1de734827a69801ca088ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0a045e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33ac0", {"tracer": "callTracer"}],"id":1}' + -d '{"jsonrpc": "2.0", "method": "debug_traceBlock", "params": ["0xf90277f90208a05a41d0e66b4120775176c09fcf39e7c0520517a13d2b57b18d33d342df038bfca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e6a7a1d47ff21b6321162aea7c6cb457d5476bcaa00e0df2706b0a4fb8bd08c9246d472abbe850af446405d9eba1db41db18b4a169a04513310fcb9f6f616972a3b948dc5d547f280849a87ebb5af0191f98b87be598a0fe2bf2a941abf41d72637e5b91750332a30283efd40c424dc522b77e6f0ed8c4b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000860153886c1bbd82b44382520b8252088455c426598b657468706f6f6c2e6f7267a0b48c515a9dde8d346c3337ea520aa995a4738bb595495506125449c1149d6cf488ba4f8ecd18aab215f869f86780862d79883d2000825208945df9b87991262f6ba471f09758cde1c0fc1de734827a69801ca088ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0a045e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33ac0", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbyhash.md b/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbyhash.md index 0be357dda21..a388552e957 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbyhash.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbyhash.md @@ -37,7 +37,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"method":"debug_traceBlockByHash","params":["0xec8cb29209d9170b31008738ec9e80acc22257249cfd0f4bce19590cd09834c8", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' + -d '{"jsonrpc": "2.0", "method": "debug_traceBlockByHash", "params": ["0xec8cb29209d9170b31008738ec9e80acc22257249cfd0f4bce19590cd09834c8", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbynumber.md b/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbynumber.md index e133112e41a..f80ec1aaa07 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbynumber.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_traceblockbynumber.md @@ -38,8 +38,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"method":"debug_traceBlockByNumber","params":["0x4d0c", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' - + -d '{"jsonrpc": "2.0", "method": "debug_traceBlockByNumber", "params": ["0x4d0c", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_tracecall.md b/services/reference/mantle/json-rpc-methods/debug/debug_tracecall.md index 1ab06262fe3..b9a07e88178 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_tracecall.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_tracecall.md @@ -53,7 +53,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"method":"debug_traceCall","params":[{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"}, "latest", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' + -d '{"jsonrpc": "2.0", "method": "debug_traceCall", "params": [{"to": "0x6b175474e89094c44da98b954eedeac495271d0f", "data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"}, "latest", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/mantle/json-rpc-methods/debug/debug_tracetransaction.md b/services/reference/mantle/json-rpc-methods/debug/debug_tracetransaction.md index 5b62c1e3919..1bf05a2b141 100644 --- a/services/reference/mantle/json-rpc-methods/debug/debug_tracetransaction.md +++ b/services/reference/mantle/json-rpc-methods/debug/debug_tracetransaction.md @@ -39,7 +39,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu curl https://mantle-mainnet.infura.io/v3/ \ -X POST \ -H "Content-Type: application/json" \ - -d '{"method":"debug_traceTransaction","params":["0xdcecf3f9fc68c92276d6c4b40c17b185f8a3fcb9d1a959a495d38d480782404b", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}' + -d '{"jsonrpc": "2.0", "method": "debug_traceTransaction", "params": ["0xdcecf3f9fc68c92276d6c4b40c17b185f8a3fcb9d1a959a495d38d480782404b", {"tracer": "callTracer"}], "id": 1}' ``` diff --git a/services/reference/mantle/quickstart.md b/services/reference/mantle/quickstart.md index f775c0d5624..e4f5dcbba88 100644 --- a/services/reference/mantle/quickstart.md +++ b/services/reference/mantle/quickstart.md @@ -172,7 +172,7 @@ In these examples, you'll use [NPM](https://docs.npmjs.com/downloading-and-insta "id": 1 } - headers = {"content-typ": "application/json"} + headers = {"content-type": "application/json"} response = requests.post(url, data=json.dumps(payload), headers=headers).json() diff --git a/services/reference/optimism/json-rpc-methods/_eth_estimategas-request.mdx b/services/reference/optimism/json-rpc-methods/_eth_estimategas-request.mdx index c39eb37d500..9c3157e614a 100644 --- a/services/reference/optimism/json-rpc-methods/_eth_estimategas-request.mdx +++ b/services/reference/optimism/json-rpc-methods/_eth_estimategas-request.mdx @@ -6,9 +6,9 @@ import TabItem from "@theme/TabItem" ```bash curl https://optimism-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc":"2.0", "method": "eth_estimateGas", "params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "value": "0x9184e72a"}], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_estimateGas", "params": [{"from": "0x9cE564c7d09f88E7d8233Cdd3A4d7AC42aBFf3aC", "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", "value": "0x9184e72a"}], "id": 1}' ``` diff --git a/services/reference/optimism/json-rpc-methods/_eth_getblockbyhash-request.mdx b/services/reference/optimism/json-rpc-methods/_eth_getblockbyhash-request.mdx index c3ab3c1e710..6e546c2c67c 100644 --- a/services/reference/optimism/json-rpc-methods/_eth_getblockbyhash-request.mdx +++ b/services/reference/optimism/json-rpc-methods/_eth_getblockbyhash-request.mdx @@ -6,16 +6,16 @@ import TabItem from "@theme/TabItem" ```bash curl https://optimism-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35", false], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35", false], "id": 1}' ``` ```bash -wscat -c wss://optimism-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",false], "id": 1}' +wscat -c wss://optimism-mainnet.infura.io/ws/v3/YOUR-API-KEY -x '{"jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": ["0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35", false], "id": 1}' ``` diff --git a/services/reference/palm/quickstart.md b/services/reference/palm/quickstart.md index 3f4f297f165..bcd2f744b6a 100644 --- a/services/reference/palm/quickstart.md +++ b/services/reference/palm/quickstart.md @@ -25,9 +25,9 @@ Run the following command in your terminal, replacing `YOUR-API-KEY` with your a ```bash curl https://palm-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' ``` ### Node (JavaScript) diff --git a/services/reference/polygon-pos/quickstart.md b/services/reference/polygon-pos/quickstart.md index 8c0e58650eb..161aed0d1f6 100644 --- a/services/reference/polygon-pos/quickstart.md +++ b/services/reference/polygon-pos/quickstart.md @@ -25,9 +25,9 @@ Run the following command in your terminal, replacing `YOUR-API-KEY` with your a ```bash curl https://polygon-mainnet.infura.io/v3/YOUR-API-KEY \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' ``` ### Node (JavaScript) @@ -166,10 +166,10 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://polygon-mainnet.infura.io/v3/YOUR-API-KEY" payload = { - "jsonrpc": "2.0", - "method": "eth_blockNumber", - "params": [], - "id": 1 + "jsonrpc": "2.0", + "method": "eth_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/starknet/quickstart.md b/services/reference/starknet/quickstart.md index 01c5b8d753f..aea5e45ed7f 100644 --- a/services/reference/starknet/quickstart.md +++ b/services/reference/starknet/quickstart.md @@ -130,11 +130,11 @@ In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-insta url = "https://starknet-mainnet.infura.io/v3/YOUR-API-KEY" - payload = - "jsonrpc": "2.0", - "method": "starknet_blockNumber", - "params": [], - "id": 1 + payload = { + "jsonrpc": "2.0", + "method": "starknet_blockNumber", + "params": [], + "id": 1 } headers = {"content-type": "application/json"} diff --git a/services/reference/zksync/json-rpc-methods/zks_getmaincontract.mdx b/services/reference/zksync/json-rpc-methods/zks_getmaincontract.mdx index a3c731d6e10..2d94b4566ee 100644 --- a/services/reference/zksync/json-rpc-methods/zks_getmaincontract.mdx +++ b/services/reference/zksync/json-rpc-methods/zks_getmaincontract.mdx @@ -25,7 +25,7 @@ Replace `YOUR-API-KEY` with an API key from your [Infura dashboard](https://infu ```bash - curl https://zksync-mainnet.infura.io/v3/YOUR-API-KEY \ +curl https://zksync-mainnet.infura.io/v3/YOUR-API-KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 1, "method": "zks_getMainContract", "params": []}' diff --git a/services/tutorials/ethereum/retrieve-the-balance-of-an-erc-20-token.md b/services/tutorials/ethereum/retrieve-the-balance-of-an-erc-20-token.md index 941afee46b5..0cf925cad6a 100644 --- a/services/tutorials/ethereum/retrieve-the-balance-of-an-erc-20-token.md +++ b/services/tutorials/ethereum/retrieve-the-balance-of-an-erc-20-token.md @@ -109,8 +109,8 @@ Create the below `async` function `getTokenBalance` that accomplishes this by in ```javascript async function getTokenBalance() { - const result = await.contract.methods.balanceOf(tokenHolder).call(); - console.log(result) + const result = await.contract.methods.balanceOf(tokenHolder).call(); + console.log(result) } getTokenBalance(); diff --git a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-ethers.md b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-ethers.md index f31a85ba523..ecb89583dc0 100644 --- a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-ethers.md +++ b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-ethers.md @@ -75,31 +75,33 @@ Replace `to_account` with the relevant details. ```go const { ethers } = require("ethers"); - async function main() { - // Configuring the connection to an Ethereum node - const network = process.env.ETHEREUM_NETWORK; - const provider = new ethers.providers.InfuraProvider( - network, - process.env.INFURA_API_KEY - ); - // Creating a signing account from a private key - const signer = new ethers.Wallet(process.env.SIGNER_PRIVATE_KEY, provider); - - // Creating and sending the transaction object - const tx = await signer.sendTransaction({ - to: "", - value: ethers.utils.parseUnits("0.001", "ether"), - }); - console.log("Mining transaction..."); - console.log(`https://${network}.etherscan.io/tx/${tx.hash}`); - // Waiting for the transaction to be mined - const receipt = await tx.wait(); - // The transaction is now on chain! - console.log(`Mined in block ${receipt.blockNumber}`); - } - - require("dotenv").config(); - main(); +async function main() { + // Configuring the connection to an Ethereum node + const network = process.env.ETHEREUM_NETWORK; + const provider = new ethers.providers.InfuraProvider( + network, + process.env.INFURA_API_KEY + ); + + // Creating a signing account from a private key + const signer = new ethers.Wallet(process.env.SIGNER_PRIVATE_KEY, provider); + + // Creating and sending the transaction object + const tx = await signer.sendTransaction({ + to: "", + value: ethers.utils.parseUnits("0.001", "ether"), + }); + console.log("Mining transaction..."); + console.log(`https://${network}.etherscan.io/tx/${tx.hash}`); + + // Waiting for the transaction to be mined + const receipt = await tx.wait(); + // The transaction is now on chain! + console.log(`Mined in block ${receipt.blockNumber}`); +} + +require("dotenv").config(); +main(); ``` ### 5. Execute the transaction diff --git a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-go.md b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-go.md index b6e9ec49b7b..986c1d4b9c5 100644 --- a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-go.md +++ b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-go.md @@ -49,82 +49,80 @@ go get github.com/ethereum/go-ethereum/rpc@v1.10.17 package main import ( - "context" - "crypto/ecdsa" - "fmt" - "log" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" + "context" + "crypto/ecdsa" + "fmt" + "log" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" ) func main() { - client, err := ethclient.Dial("https://sepolia.infura.io/v3/API_KEY") - if err != nil { - log.Fatal(err) - } - - privateKey, err := crypto.HexToECDSA("PRIVATE_KEY") - if err != nil { - log.Fatal(err) - } - - publicKey := privateKey.Public() - publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) - if !ok { - log.Fatal("error casting public key to ECDSA") - } - - fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) - - nonce, err := client.PendingNonceAt(context.Background(), fromAddress) - if err != nil { - log.Fatal(err) - } - - value := big.NewInt(10000000000000000) // in wei (0.01 eth) - gasLimit := uint64(21000) // in units - tip := big.NewInt(2000000000) // maxPriorityFeePerGas = 2 Gwei - feeCap := big.NewInt(20000000000) // maxFeePerGas = 20 Gwei - if err != nil { - log.Fatal(err) - } - - toAddress := common.HexToAddress("ADDRESS_TO") - var data []byte - - chainID, err := client.NetworkID(context.Background()) - if err != nil { - log.Fatal(err) - } - - tx := types.NewTx(&types.DynamicFeeTx{ - ChainID: chainID, - Nonce: nonce, - GasFeeCap: feeCap, - GasTipCap: tip, - Gas: gasLimit, - To: &toAddress, - Value: value, - Data: data, - }) - - signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(chainID), privateKey) - - if err != nil { - log.Fatal(err) - } - - err = client.SendTransaction(context.Background(), signedTx) - if err != nil { - log.Fatal(err) - } - - fmt.Printf("Transaction hash: %s", signedTx.Hash().Hex()) - + client, err := ethclient.Dial("https://sepolia.infura.io/v3/API_KEY") + if err != nil { + log.Fatal(err) + } + + privateKey, err := crypto.HexToECDSA("PRIVATE_KEY") + if err != nil { + log.Fatal(err) + } + + publicKey := privateKey.Public() + publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) + if !ok { + log.Fatal("error casting public key to ECDSA") + } + + fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) + + nonce, err := client.PendingNonceAt(context.Background(), fromAddress) + if err != nil { + log.Fatal(err) + } + + value := big.NewInt(10000000000000000) // in wei (0.01 eth) + gasLimit := uint64(21000) // in units + tip := big.NewInt(2000000000) // maxPriorityFeePerGas = 2 Gwei + feeCap := big.NewInt(20000000000) // maxFeePerGas = 20 Gwei + if err != nil { + log.Fatal(err) + } + + toAddress := common.HexToAddress("ADDRESS_TO") + var data []byte + + chainID, err := client.NetworkID(context.Background()) + if err != nil { + log.Fatal(err) + } + + tx := types.NewTx(&types.DynamicFeeTx{ + ChainID: chainID, + Nonce: nonce, + GasFeeCap: feeCap, + GasTipCap: tip, + Gas: gasLimit, + To: &toAddress, + Value: value, + Data: data, + }) + + signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(chainID), privateKey) + if err != nil { + log.Fatal(err) + } + + err = client.SendTransaction(context.Background(), signedTx) + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Transaction hash: %s", signedTx.Hash().Hex()) } ``` diff --git a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-py.md b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-py.md index 02ab0e8b41f..4a2df5df804 100644 --- a/services/tutorials/ethereum/send-a-transaction/send-a-transaction-py.md +++ b/services/tutorials/ethereum/send-a-transaction/send-a-transaction-py.md @@ -73,35 +73,35 @@ from web3 import Web3, exceptions load_dotenv() -infura_url = 'https://sepolia.infura.io/v3/' -private_key = os.getenv('PRIVATE_KEY') -from_account = '' -to_account = '' +infura_url = "https://sepolia.infura.io/v3/" +private_key = os.getenv("PRIVATE_KEY") +from_account = "" +to_account = "" web3 = Web3(Web3.HTTPProvider(infura_url)) try: - from_account = web3.to_checksum_address(from_account) + from_account = web3.to_checksum_address(from_account) except exceptions.InvalidAddress: - print(f"Invalid 'from_account' address: {from_account}") + print(f"Invalid 'from_account' address: {from_account}") try: - to_account = web3.to_checksum_address(to_account) + to_account = web3.to_checksum_address(to_account) except exceptions.InvalidAddress: - print(f"Invalid 'to_account' address: {to_account}") + print(f"Invalid 'to_account' address: {to_account}") nonce = web3.eth.get_transaction_count(from_account) tx = { - 'type': '0x2', - 'nonce': nonce, - 'from': from_account, - 'to': to_account, - 'value': web3.to_wei(0.01, 'ether'), - 'maxFeePerGas': web3.to_wei('250', 'gwei'), - 'maxPriorityFeePerGas': web3.to_wei('3', 'gwei'), - 'chainId': 11155111 + "type": "0x2", + "nonce": nonce, + "from": from_account, + "to": to_account, + "value": web3.to_wei(0.01, "ether"), + "maxFeePerGas": web3.to_wei("250", "gwei"), + "maxPriorityFeePerGas": web3.to_wei("3", "gwei"), + "chainId": 11155111 } gas = web3.eth.estimate_gas(tx) -tx['gas'] = gas +tx["gas"] = gas signed_tx = web3.eth.account.sign_transaction(tx, private_key) tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction) print("Transaction hash: " + str(web3.to_hex(tx_hash))) diff --git a/services/tutorials/ethereum/send-a-transaction/use-ethers.js-infuraprovider-or-web3provider.md b/services/tutorials/ethereum/send-a-transaction/use-ethers.js-infuraprovider-or-web3provider.md index 49fb788c6ed..2a1d9130ecb 100644 --- a/services/tutorials/ethereum/send-a-transaction/use-ethers.js-infuraprovider-or-web3provider.md +++ b/services/tutorials/ethereum/send-a-transaction/use-ethers.js-infuraprovider-or-web3provider.md @@ -207,7 +207,7 @@ Next, create the `sendTransaction()` function that sends the transaction. Place value: ethers.utils.parseEther(amount) }); console.log("tx", tx); - setTxSent('Transaction initiated! Tx hash: ' + tx.hash); + setTxSent("Transaction initiated! Tx hash: " + tx.hash); } } else // InfuraProvider @@ -217,9 +217,9 @@ Next, create the `sendTransaction()` function that sends the transaction. Place value: ethers.utils.parseEther(amount) }); console.log("tx", tx); - setTxSentInfura('Transaction initiated! Tx hash: ' + tx.hash); + setTxSentInfura("Transaction initiated! Tx hash: " + tx.hash); } - }Ja + } ``` ### 5. Run the app diff --git a/services/tutorials/ethereum/send-a-transaction/use-rust.md b/services/tutorials/ethereum/send-a-transaction/use-rust.md index 9ce67b63463..5d6c37baab2 100644 --- a/services/tutorials/ethereum/send-a-transaction/use-rust.md +++ b/services/tutorials/ethereum/send-a-transaction/use-rust.md @@ -62,57 +62,56 @@ Open the Rust source `src/main.rs` and replace its contents with the following c ```rust showLineNumbers use ethers::{ - core::{types::TransactionRequest}, - middleware::SignerMiddleware, - providers::{Http, Middleware, Provider}, - signers::{LocalWallet, Signer}, - utils, - prelude::* + core::{types::TransactionRequest}, + middleware::SignerMiddleware, + providers::{Http, Middleware, Provider}, + signers::{LocalWallet, Signer}, + utils, + prelude::* }; use eyre::Result; use std::convert::TryFrom; #[tokio::main] async fn main() -> Result<()> { + // Connect to the network + let provider = Provider::::try_from("https://sepolia.infura.io/v3/INFURA_API_KEY")?; - // Connect to the network - let provider = Provider::::try_from("https://sepolia.infura.io/v3/INFURA_API_KEY")?; + let chain_id = provider.get_chainid().await?; - let chain_id = provider.get_chainid().await?; + // Define the signer. + // Replace the SIGNER_PRIVATE_KEY with + // the private key of your Ethereum account (without the 0x prefix). + // However, we recommended that you load it from + // an .env file or external vault. + let wallet: LocalWallet = "SIGNER_PRIVATE_KEY" + .parse::()? + .with_chain_id(chain_id.as_u64()); - // Define the signer. - // Replace the SIGNER_PRIVATE_KEY with - // the private key of your Ethereum account (without the 0x prefix). - // However, we recommended that you load it from - // an .env file or external vault. - let wallet: LocalWallet = "SIGNER_PRIVATE_KEY" - .parse::()? - .with_chain_id(chain_id.as_u64()); + let to_address = "0xAED01C776d98303eE080D25A21f0a42D94a86D9c"; - let to_address = "0xAED01C776d98303eE080D25A21f0a42D94a86D9c"; + // Connect the wallet to the provider + let client = SignerMiddleware::new(provider, wallet); - // connect the wallet to the provider - let client = SignerMiddleware::new(provider, wallet); + // Craft the transaction + // The below code knows how to figure out the + // default gas value and determine the next nonce + // so you do not need to explicitly add them. + let tx = TransactionRequest::new() + .to(to_address) + .value(U256::from(utils::parse_ether(0.01)?)); - // Craft the transaction - // The below code knows how to figure out the - // default gas value and determine the next nonce - // so you do not need to explicitly add them. - let tx = TransactionRequest::new() - .to(to_address) - .value(U256::from(utils::parse_ether(0.01)?)); + // Send it! + let pending_tx = client.send_transaction(tx, None).await?; - // send it! - let pending_tx = client.send_transaction(tx, None).await?; + // Get the mined tx + let receipt = pending_tx.await?.ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?; + let tx = client.get_transaction(receipt.transaction_hash).await?; - // get the mined tx - let receipt = pending_tx.await?.ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?; - let tx = client.get_transaction(receipt.transaction_hash).await?; + println!("Sent tx: {}\n", serde_json::to_string(&tx)?); + println!("Tx receipt: {}", serde_json::to_string(&receipt)?); - println!("Sent tx: {}\n", serde_json::to_string(&tx)?); - println!("Tx receipt: {}", serde_json::to_string(&receipt)?); - - Ok(()) + Ok(()) } ``` @@ -136,18 +135,54 @@ From the `infura_rs` directory, run the code. cargo run ``` -You will see an output similar to the following. +You will see an output similar to the following: + :::note Use the wrap button Use the wrap button on the top right of the below code block window for wrapped display. ::: ```log Compiling infura_rs v0.1.0 (/Users/rajkaramchedu/onboarding/traian-tutorials/infura_rs) - Finished dev [unoptimized + debuginfo] target(s) in 2.14s - Running `target/debug/infura_rs` -Sent tx: {"hash":"0x3cb5a5fac18e889457905351c9950108873a8f0789fe83e8a733b8367f49a67a","nonce":"0x1","blockHash":"0xa2787f5ec22d491588a8ffc6e7cec3ed97fccac4845e448650d02fce672a657c","blockNumber":"0x3a7608","transactionIndex":"0x3d","from":"0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb","to":"0xaed01c776d98303ee080d25a21f0a42d94a86d9c","value":"0x2386f26fc10000","gasPrice":"0x3cc","gas":"0x5208","input":"0x","v":"0x1546d71","r":"0x92aa9fe6039946db5ea291a245529a5d67f5531e95d74c483fe8283cca9ec666","s":"0x4a5c0de8e64c79659965fb36f2b0ea1d295ae868f5f65809ef4cf1ef55239e09","type":"0x0","chainId":"0xaa36a7"} +Finished dev [unoptimized + debuginfo] target(s) in 2.14s +Running `target/debug/infura_rs` + +Sent tx: +{ + "hash": "0x3cb5a5fac18e889457905351c9950108873a8f0789fe83e8a733b8367f49a67a", + "nonce": "0x1", + "blockHash": "0xa2787f5ec22d491588a8ffc6e7cec3ed97fccac4845e448650d02fce672a657c", + "blockNumber": "0x3a7608", + "transactionIndex": "0x3d", + "from": "0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb", + "to": "0xaed01c776d98303ee080d25a21f0a42d94a86d9c", + "value": "0x2386f26fc10000", + "gasPrice": "0x3cc", + "gas": "0x5208", + "input": "0x", + "v": "0x1546d71", + "r": "0x92aa9fe6039946db5ea291a245529a5d67f5531e95d74c483fe8283cca9ec666", + "s": "0x4a5c0de8e64c79659965fb36f2b0ea1d295ae868f5f65809ef4cf1ef55239e09", + "type": "0x0", + "chainId": "0xaa36a7" +} -Tx receipt: {"transactionHash":"0x3cb5a5fac18e889457905351c9950108873a8f0789fe83e8a733b8367f49a67a","transactionIndex":"0x3d","blockHash":"0xa2787f5ec22d491588a8ffc6e7cec3ed97fccac4845e448650d02fce672a657c","blockNumber":"0x3a7608","from":"0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb","to":"0xaed01c776d98303ee080d25a21f0a42d94a86d9c","cumulativeGasUsed":"0x406e87","gasUsed":"0x5208","contractAddress":null,"logs":[],"status":"0x1","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","type":"0x0","effectiveGasPrice":"0x3cc"} +Tx receipt: +{ + "transactionHash": "0x3cb5a5fac18e889457905351c9950108873a8f0789fe83e8a733b8367f49a67a", + "transactionIndex": "0x3d", + "blockHash": "0xa2787f5ec22d491588a8ffc6e7cec3ed97fccac4845e448650d02fce672a657c", + "blockNumber": "0x3a7608", + "from": "0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb", + "to": "0xaed01c776d98303ee080d25a21f0a42d94a86d9c", + "cumulativeGasUsed": "0x406e87", + "gasUsed": "0x5208", + "contractAddress": null, + "logs": [], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x0", + "effectiveGasPrice": "0x3cc" +} ``` In the above transaction receipt, the transaction type shows `"type":"0x0"` indicating that this was a legacy transaction. Next, we will send an EIP-1559 transaction, which is of the type `"type":"0x2"`. @@ -160,12 +195,12 @@ To send an EIP-1559 transaction, i.e., of the `"type":"0x2"` you must use `Eip15 ```rust showLineNumbers use ethers::{ - core::{types::TransactionRequest}, - middleware::SignerMiddleware, - providers::{Http, Middleware, Provider}, - signers::{LocalWallet, Signer}, - utils, - prelude::* + core::{types::TransactionRequest}, + middleware::SignerMiddleware, + providers::{Http, Middleware, Provider}, + signers::{LocalWallet, Signer}, + utils, + prelude::* }; use eyre::Result; use std::convert::TryFrom; @@ -173,44 +208,44 @@ use types::Eip1559TransactionRequest; #[tokio::main] async fn main() -> Result<()> { + // Connect to the network + let provider = Provider::::try_from("https://sepolia.infura.io/v3/INFURA_API_KEY")?; - // connect to the network - let provider = Provider::::try_from("https://sepolia.infura.io/v3/INFURA_API_KEY")?; - - let chain_id = provider.get_chainid().await?; + let chain_id = provider.get_chainid().await?; - // Define the signer. - // Replace the SIGNER_PRIVATE_KEY with - // the private key of your Ethereum account (without the 0x prefix). - // However, we recommended that you load it from - // an .env file or external vault. - let wallet: LocalWallet = "SIGNER_PRIVATE_KEY" - .parse::()? - .with_chain_id(chain_id.as_u64()); + // Define the signer. + // Replace the SIGNER_PRIVATE_KEY with + // the private key of your Ethereum account (without the 0x prefix). + // However, we recommended that you load it from + // an .env file or external vault. + let wallet: LocalWallet = "SIGNER_PRIVATE_KEY" + .parse::()? + .with_chain_id(chain_id.as_u64()); - let to_address = "0xAED01C776d98303eE080D25A21f0a42D94a86D9c"; + let to_address = "0xAED01C776d98303eE080D25A21f0a42D94a86D9c"; - // connect the wallet to the provider - let client = SignerMiddleware::new(provider, wallet); + // Connect the wallet to the provider + let client = SignerMiddleware::new(provider, wallet); - // craft the transaction - // this also knows to estimate the `max_priority_fee_per_gas` but added it manually just to see how it would look - let tx = Eip1559TransactionRequest::new() - .to(to_address) - .value(U256::from(utils::parse_ether(0.01)?)) - .max_priority_fee_per_gas(U256::from(2000000000_u128)); // 2 Gwei + // Craft the transaction + // This also knows to estimate the `max_priority_fee_per_gas` + // but added it manually just to see how it would look + let tx = Eip1559TransactionRequest::new() + .to(to_address) + .value(U256::from(utils::parse_ether(0.01)?)) + .max_priority_fee_per_gas(U256::from(2000000000_u128)); // 2 Gwei - // send it! - let pending_tx = client.send_transaction(tx, None).await?; + // Send it! + let pending_tx = client.send_transaction(tx, None).await?; - // get the mined tx - let receipt = pending_tx.await?.ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?; - let tx = client.get_transaction(receipt.transaction_hash).await?; + // Get the mined tx + let receipt = pending_tx.await?.ok_or_else(|| eyre::format_err!("tx dropped from mempool"))?; + let tx = client.get_transaction(receipt.transaction_hash).await?; - println!("Sent tx: {}\n", serde_json::to_string(&tx)?); - println!("Tx receipt: {}", serde_json::to_string(&receipt)?); + println!("Sent tx: {}\n", serde_json::to_string(&tx)?); + println!("Tx receipt: {}", serde_json::to_string(&receipt)?); - Ok(()) + Ok(()) } ``` @@ -235,11 +270,50 @@ warning: unused import: `types::TransactionRequest` = note: `#[warn(unused_imports)]` on by default warning: `infura_rs` (bin "infura_rs") generated 1 warning (run `cargo fix --bin "infura_rs"` to apply 1 suggestion) - Finished dev [unoptimized + debuginfo] target(s) in 2.42s - Running `target/debug/infura_rs` -Sent tx: {"hash":"0xbbc036f4dfe00b590c3693b8a2516316dec5748b3e4085ec92dfc040d8b8492b","nonce":"0x4","blockHash":"0xe64a029af23b18738a69c6eab19b85d99dc2844e8ce54a4bedcc1a75fe18dc08","blockNumber":"0x3a7a42","transactionIndex":"0xf","from":"0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb","to":"0xaed01c776d98303ee080d25a21f0a42d94a86d9c","value":"0x2386f26fc10000","gasPrice":"0x7735940c","gas":"0x5208","input":"0x","v":"0x1","r":"0xa0e4125501b3146910750408adaa255cd3e3a06461e311e1146a0983fcd9b0e0","s":"0x35c5c6cf6650dcff0ed1e25689d0ce17f7f5986342276f11651976c7048172d1","type":"0x2","accessList":[],"maxPriorityFeePerGas":"0x77359400","maxFeePerGas":"0xb2d05e16","chainId":"0xaa36a7"} +Finished dev [unoptimized + debuginfo] target(s) in 2.42s +Running `target/debug/infura_rs` + +Sent tx: +{ + "hash": "0xbbc036f4dfe00b590c3693b8a2516316dec5748b3e4085ec92dfc040d8b8492b", + "nonce": "0x4", + "blockHash": "0xe64a029af23b18738a69c6eab19b85d99dc2844e8ce54a4bedcc1a75fe18dc08", + "blockNumber": "0x3a7a42", + "transactionIndex": "0xf", + "from": "0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb", + "to": "0xaed01c776d98303ee080d25a21f0a42d94a86d9c", + "value": "0x2386f26fc10000", + "gasPrice": "0x7735940c", + "gas": "0x5208", + "input": "0x", + "v": "0x1", + "r": "0xa0e4125501b3146910750408adaa255cd3e3a06461e311e1146a0983fcd9b0e0", + "s": "0x35c5c6cf6650dcff0ed1e25689d0ce17f7f5986342276f11651976c7048172d1", + "type": "0x2", + "accessList": [], + "maxPriorityFeePerGas": "0x77359400", + "maxFeePerGas": "0xb2d05e16", + "chainId": "0xaa36a7" +} -Tx receipt: {"transactionHash":"0xbbc036f4dfe00b590c3693b8a2516316dec5748b3e4085ec92dfc040d8b8492b","transactionIndex":"0xf","blockHash":"0xe64a029af23b18738a69c6eab19b85d99dc2844e8ce54a4bedcc1a75fe18dc08","blockNumber":"0x3a7a42","from":"0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb","to":"0xaed01c776d98303ee080d25a21f0a42d94a86d9c","cumulativeGasUsed":"0x6a7187","gasUsed":"0x5208","contractAddress":null,"logs":[],"status":"0x1","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","type":"0x2","effectiveGasPrice":"0x7735940c"} +Tx receipt: +{ + "transactionHash": "0xbbc036f4dfe00b590c3693b8a2516316dec5748b3e4085ec92dfc040d8b8492b", + "transactionIndex": "0xf", + "blockHash": "0xe64a029af23b18738a69c6eab19b85d99dc2844e8ce54a4bedcc1a75fe18dc08", + "blockNumber": "0x3a7a42", + "from": "0xe33fef60722ba79989aeaa1b6e6daf7f351c0fbb", + "to": "0xaed01c776d98303ee080d25a21f0a42d94a86d9c", + "cumulativeGasUsed": "0x6a7187", + "gasUsed": "0x5208", + "contractAddress": null, + "logs": [], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "effectiveGasPrice": "0x7735940c" +} ``` -Ignore the `"warning: unused import: types::TransactionRequest"` above. In the above transaction receipt, the transaction type shows `"type":"0x2"` indicating that this was an EIP-1559 transaction. +Ignore the `"warning: unused import: types::TransactionRequest"`. +In the above transaction receipt, the transaction type shows `"type":"0x2"` indicating that this was an EIP-1559 transaction. diff --git a/services/tutorials/ethereum/subscribe-to-pending-transactions.md b/services/tutorials/ethereum/subscribe-to-pending-transactions.md index 5efeff8f432..1cebebc6880 100644 --- a/services/tutorials/ethereum/subscribe-to-pending-transactions.md +++ b/services/tutorials/ethereum/subscribe-to-pending-transactions.md @@ -57,8 +57,8 @@ Connect to Infura’s WebSockets endpoint to subscribe to new pending transactio Define the following endpoints in your file: ```python -infura_ws_url = 'wss://goerli.infura.io/ws/v3/' -infura_http_url = 'https://goerli.infura.io/v3/' +infura_ws_url = "wss://goerli.infura.io/ws/v3/" +infura_http_url = "https://goerli.infura.io/v3/" web3 = Web3(Web3.HTTPProvider(infura_http_url)) ``` @@ -77,7 +77,7 @@ async def get_event(): async with connect(infura_ws_url) as ws: await ws.send('{"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}') subscription_response = await ws.recv() - print(subscription_response) # {"jsonrpc":"2.0","id":1,"result":"0xd67da23f62a01f58042bc73d3f1c8936"} + print(subscription_response) # {"jsonrpc": "2.0", "id": 1, "result": "0xd67da23f62a01f58042bc73d3f1c8936"} ``` In the method we use `ws.send()` to start a new subscription for new pending transactions, after which we get a confirmation back from the node with our subscription ID. @@ -100,9 +100,9 @@ Finally, we'll add an `if __name__ == "__main__"` statement, so that our program ```python if __name__ == "__main__": - loop = asyncio.get_event_loop() - while True: - loop.run_until_complete(get_event()) + loop = asyncio.get_event_loop() + while True: + loop.run_until_complete(get_event()) ``` The complete code sample should now look as follows: @@ -164,7 +164,7 @@ You should now see the terminal fill up with Ethereum transfers: You can update the program to monitor incoming transactions to a specific Ethereum address. Let’s define an account we’d like to monitor first, outside of the `get_event()` function: ```python -account = '' +account = "" ``` Then, inside the function and `try` block, append the following to check whether the recipient is the address we specified, after which it will print the transaction hash, sender address, and the value sent in Ether. diff --git a/services/tutorials/ethereum/track-erc-721-and-erc-1155-token-transfers.md b/services/tutorials/ethereum/track-erc-721-and-erc-1155-token-transfers.md index 313ed992058..ce0ec353f4e 100644 --- a/services/tutorials/ethereum/track-erc-721-and-erc-1155-token-transfers.md +++ b/services/tutorials/ethereum/track-erc-721-and-erc-1155-token-transfers.md @@ -176,9 +176,9 @@ console.log( You can set the listener for the `subscription1155` created in [step 4](track-erc-721-and-erc-1155-token-transfers.md#4.-subscribe-to-contract-events) by adding the following lines to the script: ```javascript -subscription1155.on('data', event => { - ... -}); +subscription1155.on("data", event => { + // ... +}) ``` As with ERC-721 in [Step 5](track-erc-721-and-erc-1155-token-transfers.md#5.-read-erc-721-transfers), add the ERC-1155 ABI to the listener: @@ -259,7 +259,7 @@ You can track a specific address sending a specific token, by checking for both ```javascript -if (event.address == '' && transaction.tokenId == ) { ('console.log('Specified ERC-721 NFT was transferred!') }; +if (event.address == "" && transaction.tokenId == ) { console.log("Specified ERC-721 NFT was transferred!"); } ```