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
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Copy file name to clipboardexpand all lines: docs/docs/guides/smart_contracts/deploying_and_interacting_with_smart_contracts.md
+16-10
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
sidebar_position: 1
3
-
sidebar_label: 'Deploying and Interacting with Smart Contracts'
3
+
sidebar_label: 'Tutorial: Deploying and Interacting with Smart Contracts'
4
4
---
5
5
6
6
import Tabs from '@theme/Tabs';
@@ -24,6 +24,12 @@ Here is a high-level overview of the steps we will be taking in this tutorial:
24
24
6. Deploy the smart contract to the Ganache network using web3.js.
25
25
7. Interact with the smart contract using web3.js.
26
26
27
+
:::tip
28
+
📝 **Community support:**
29
+
If you encounter any issues while following this guide or have questions, don't hesitate to seek assistance. Our friendly community is ready to help you out!
30
+
Join our [Discord](https://discord.gg/F4NUfaCC) server and head to the **#web3js-general** channel to connect with other developers and get the support you need.
31
+
:::
32
+
27
33
## Step 1: Setting up the Environment
28
34
29
35
Before we start writing and deploying our contract, we need to set up our environment. For that, we need to install the following:
@@ -108,9 +114,9 @@ Next, create a new file called `compile.js` in your project directory and add th
108
114
// This code will compile smart contract and generate its ABI and bytecode
109
115
// Alternatively, you can use something like `npm i solc && npx solcjs MyContract.sol --bin --abi`
110
116
111
-
importsolcfrom'solc';
112
-
importpathfrom'path';
113
-
importfsfrom'fs';
117
+
constsolc=require( 'solc');
118
+
constpath=require('path');
119
+
constfs=require('fs');
114
120
115
121
constfileName='MyContract.sol';
116
122
constcontractName='MyContract';
@@ -340,20 +346,20 @@ async function deploy() {
340
346
constdefaultAccount= providersAccounts[0];
341
347
console.log('deployer account:', defaultAccount);
342
348
343
-
constdeployedContract=myContract.deploy({
349
+
constcontractDeployer=myContract.deploy({
344
350
data:'0x'+ bytecode,
345
351
arguments: [1],
346
352
});
347
353
348
354
// optionally, estimate the gas that will be used for development and log it
349
-
constgas=awaitdeployedContract.estimateGas({
355
+
constgas=awaitcontractDeployer.estimateGas({
350
356
from: defaultAccount,
351
357
});
352
358
console.log('estimated gas:', gas);
353
359
354
360
try {
355
361
// Deploy the contract to the Ganache network
356
-
consttx=awaitdeployedContract.send({
362
+
consttx=awaitcontractDeployer.send({
357
363
from: defaultAccount,
358
364
gas,
359
365
gasPrice:10000000000,
@@ -396,18 +402,18 @@ async function deploy(): Promise<void> {
0 commit comments