You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/developers/tutorials/sending-transactions-using-web3-and-alchemy/index.md
+14-7Lines changed: 14 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -51,10 +51,15 @@ This is what we will be using in this tutorial.
51
51
### 6\. What is the web3 library? {#what-is-the-web3-library}
52
52
53
53
- Web3.js is a wrapper library around the standard JSON-RPC calls that is quite common to use in Ethereum development.
54
-
- There are many web3 libraries for different languages. In this tutorial we’ll be using [Alchemy Web3](https://docs.alchemy.com/reference/api-overview) which is written in JavaScript. You can check out other options [here](https://docs.alchemyapi.io/guides/getting-started#other-web3-libraries).
54
+
- There are many web3 libraries for different languages. In this tutorial we’ll be using [Alchemy Web3](https://docs.alchemy.com/reference/api-overview) which is written in JavaScript. You can check out other options [here](https://docs.alchemyapi.io/guides/getting-started#other-web3-libraries) like [ethers.js](https://docs.ethers.org/v5/).
55
55
56
56
Okay, now that we have a few of these questions out of the way, let’s move on to the tutorial. Feel free to ask questions anytime in the Alchemy [discord](https://discord.gg/gWuC7zB)!
57
57
58
+
### 7\. How to send secure, gas-optimized, and private transactions? {how-to-send-secure-gas-optimized-and-private-transactions}
59
+
60
+
-[Alchemy has a suite of Transact APIs](https://docs.alchemy.com/reference/transact-api-quickstart). You can use these to send reinforced transactions, simulate transactions before they happen, send private transactions, and send gas-optimized transactions
61
+
- You can also use the [Notify API](https://docs.alchemy.com/docs/alchemy-notify) to be alerted when your transaction is pulled from the mempool and added to the chain
62
+
58
63
**NOTE:** This guide requires an Alchemy account, an Ethereum address or MetaMask wallet, NodeJs, and npm installed. If not, follow these steps:
59
64
60
65
1.[Create a free Alchemy account](https://auth.alchemyapi.io/signup)
@@ -63,13 +68,13 @@ Okay, now that we have a few of these questions out of the way, let’s move on
63
68
64
69
## Steps to Sending your Transaction {#steps-to-sending-your-transaction}
65
70
66
-
### 1\. Create an Alchemy app on the Rinkeby testnet {#create-an-alchemy-app-on-the-rinkeby-testnet}
71
+
### 1\. Create an Alchemy app on the Sepolia testnet {#create-an-alchemy-app-on-the-sepolia-testnet}
67
72
68
-
Navigate to your [Alchemy Dashboard](https://dashboard.alchemyapi.io/) and create a new app, choosing Rinkeby (or any other testnet) for your network.
73
+
Navigate to your [Alchemy Dashboard](https://dashboard.alchemyapi.io/) and create a new app, choosing Sepolia (or any other testnet) for your network.
69
74
70
-
### 2\. Request ETH from the Rinkeby faucet {#request-eth-from-rinkeby-faucet}
75
+
### 2\. Request ETH from the Sepolia faucet {#request-eth-from-sepolia-faucet}
71
76
72
-
Follow the instructions on the [Alchemy Rinkeby faucet](https://www.rinkebyfaucet.com/) to receive ETH. Make sure to include your **Rinkeby** Ethereum address (from MetaMask) and not another network. After following the instructions, double-check that you’ve received the ETH in your wallet.
77
+
Follow the instructions on the [Alchemy Sepolia faucet](https://www.sepoliafaucet.com/) to receive ETH. Make sure to include your **Sepolia** Ethereum address (from MetaMask) and not another network. After following the instructions, double-check that you’ve received the ETH in your wallet.
73
78
74
79
### 3\. Create a new project directory and `cd` into it {#create-a-new-project-direction}
75
80
@@ -84,6 +89,8 @@ cd sendtx-example
84
89
85
90
Run the following command in your project directory to install [Alchemy Web3](https://docs.alchemy.com/reference/api-overview):
86
91
92
+
Note, if you'd like to use the ethers.js library, [follow the instructions here](https://docs.alchemy.com/docs/how-to-send-transactions-on-ethereum).
93
+
87
94
```
88
95
npm install @alch/alchemy-web3
89
96
```
@@ -114,7 +121,7 @@ Don't commit <code>.env</code>! Please make sure never to share or expose your <
Great, now that we have our sensitive data protected in a `.env` file, let’s start coding. For our send transaction example, we’ll be sending ETH back to the Rinkeby faucet.
124
+
Great, now that we have our sensitive data protected in a `.env` file, let’s start coding. For our send transaction example, we’ll be sending ETH back to the Sepolia faucet.
118
125
119
126
Create a `sendTx.js` file, which is where we will configure and send our example transaction, and add the following lines of code to it:
120
127
@@ -156,7 +163,7 @@ Now, before we jump into running this code, let's talk about some of the compone
156
163
157
164
-`nonce` : The nonce specification is used to keep track of the number of transactions sent from your address. We need this for security purposes and to prevent [replay attacks](https://docs.alchemyapi.io/resources/blockchain-glossary#account-nonce). To get the number of transactions sent from your address we use [getTransactionCount](https://docs.alchemyapi.io/documentation/alchemy-api-reference/json-rpc#eth_gettransactioncount).
158
165
-`transaction`: The transaction object has a few aspects we need to specify
159
-
-`to`: This is the address we want to send ETH to. In this case, we are sending ETH back to the [Rinkeby faucet](https://faucet.rinkeby.io/) we initially requested from.
166
+
-`to`: This is the address we want to send ETH to. In this case, we are sending ETH back to the [Sepolia faucet](https://sepoliafaucet.com/) we initially requested from.
160
167
-`value`: This is the amount we wish to send, specified in Wei where 10^18 Wei = 1 ETH
161
168
-`gas`: There are many ways to determine the right amount of gas to include with your transaction. Alchemy even has a [gas price webhook](https://docs.alchemyapi.io/guides/alchemy-notify#address-activity-1) to notify you when the gas price falls within a certain threshold. For Mainnet transactions, it's good practice to check a gas estimator like [ETH Gas Station](https://ethgasstation.info/) to determine the right amount of gas to include. 21000 is the minimum amount of gas an operation on Ethereum will use, so to ensure our transaction will be executed we put 30000 here.
162
169
-`nonce`: see above nonce definition. Nonce starts counting from zero.
0 commit comments