Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit fcc5205

Browse files
Merge branch '4.x' into 6275-fix-web3ethcontractmethodsmymethod-does-not-accept-to-insert-any-parameters
2 parents d6bcd2b + f9468a8 commit fcc5205

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2415
-214
lines changed

.github/workflows/build.yml

+73-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- run: yarn prebuild
2828
- run: yarn build:cjs
2929
- run: tar -czf /tmp/web3-${{ matrix.node }}.js.tar.gz --exclude="./.git" ./
30-
- uses: actions/upload-artifact@v3
30+
- uses: actions/upload-artifact@v4
3131
with:
3232
name: web3-${{ matrix.node }}.js.tar.gz
3333
path: /tmp/web3-${{ matrix.node }}.js.tar.gz
@@ -42,7 +42,7 @@ jobs:
4242
- uses: actions/setup-node@v3
4343
with:
4444
node-version: ${{ matrix.node }}
45-
- uses: actions/download-artifact@v3
45+
- uses: actions/download-artifact@v4
4646
with:
4747
name: web3-${{ matrix.node }}.js.tar.gz
4848
path: /tmp
@@ -59,7 +59,7 @@ jobs:
5959
- uses: actions/setup-node@v3
6060
with:
6161
node-version: ${{ matrix.node }}
62-
- uses: actions/download-artifact@v3
62+
- uses: actions/download-artifact@v4
6363
with:
6464
name: web3-${{ matrix.node }}.js.tar.gz
6565
path: /tmp
@@ -73,7 +73,7 @@ jobs:
7373
- uses: actions/setup-node@v3
7474
with:
7575
node-version: 18
76-
- uses: actions/download-artifact@v3
76+
- uses: actions/download-artifact@v4
7777
with:
7878
name: web3-18.js.tar.gz
7979
path: /tmp
@@ -88,7 +88,7 @@ jobs:
8888
- uses: actions/setup-node@v3
8989
with:
9090
node-version: 18
91-
- uses: actions/download-artifact@v3
91+
- uses: actions/download-artifact@v4
9292
with:
9393
name: web3-18.js.tar.gz
9494
path: /tmp
@@ -128,7 +128,7 @@ jobs:
128128
- uses: actions/setup-node@v3
129129
with:
130130
node-version: ${{ matrix.node }}
131-
- uses: actions/download-artifact@v3
131+
- uses: actions/download-artifact@v4
132132
with:
133133
name: web3-${{ matrix.node }}.js.tar.gz
134134
path: /tmp
@@ -158,7 +158,7 @@ jobs:
158158
- uses: actions/setup-node@v3
159159
with:
160160
node-version: ${{ matrix.node }}
161-
- uses: actions/download-artifact@v3
161+
- uses: actions/download-artifact@v4
162162
with:
163163
name: web3-${{ matrix.node }}.js.tar.gz
164164
path: /tmp
@@ -183,7 +183,7 @@ jobs:
183183
- uses: actions/setup-node@v3
184184
with:
185185
node-version: ${{ matrix.node }}
186-
- uses: actions/download-artifact@v3
186+
- uses: actions/download-artifact@v4
187187
with:
188188
name: web3-${{ matrix.node }}.js.tar.gz
189189
path: /tmp
@@ -206,7 +206,7 @@ jobs:
206206
node-version: ${{ matrix.node }}
207207
- uses: browser-actions/setup-firefox@latest
208208
if: matrix.browser == 'firefox'
209-
- uses: actions/download-artifact@v3
209+
- uses: actions/download-artifact@v4
210210
with:
211211
name: web3-${{ matrix.node }}.js.tar.gz
212212
path: /tmp
@@ -230,9 +230,72 @@ jobs:
230230
- uses: actions/setup-node@v3
231231
with:
232232
node-version: ${{ matrix.node }}
233-
- uses: actions/download-artifact@v3
233+
- uses: actions/download-artifact@v4
234234
with:
235235
name: web3-${{ matrix.node }}.js.tar.gz
236236
path: /tmp
237237
- run: tar -xf /tmp/web3-${{ matrix.node }}.js.tar.gz -C ./
238238
- run: yarn build:docs
239+
240+
benchmark:
241+
name: Benchmark Tests
242+
needs: build
243+
runs-on: ubuntu-latest
244+
strategy:
245+
matrix:
246+
node: [ 18 ]
247+
steps:
248+
- uses: actions/setup-node@v3
249+
with:
250+
node-version: ${{ matrix.node }}
251+
- uses: actions/download-artifact@v4
252+
with:
253+
name: web3-${{ matrix.node }}.js.tar.gz
254+
path: /tmp
255+
- run: tar -xf /tmp/web3-${{ matrix.node }}.js.tar.gz -C ./
256+
# @octokit/core not supported on node 16, so I can't add it to the package.json
257+
- run: npm install --no-package-lock --no-save --force @octokit/core
258+
- name: Restore main branch benchmark data
259+
uses: actions/cache/restore@v3
260+
with:
261+
path: web3-benchmark-main.json
262+
key: ${{ runner.os }}-web3-benchmark-main.json
263+
- run: yarn test:benchmark
264+
- name: Compare benchmark result and make comment
265+
uses: benchmark-action/github-action-benchmark@v1
266+
with:
267+
# What benchmark tool the output.txt came from
268+
tool: 'benchmarkjs'
269+
# Where the output from the benchmark tool is stored
270+
output-file-path: benchmark-data.txt
271+
# Where the previous data file is stored
272+
external-data-json-path: web3-benchmark-main.json
273+
# Workflow will fail when an alert happens
274+
fail-on-alert: false
275+
# GitHub API token to make a commit comment
276+
github-token: ${{ secrets.GITHUB_TOKEN }}
277+
# Enable alert commit comment
278+
comment-always: true
279+
save-data-file: false
280+
# copy comment from commit to Pull Request
281+
- run: node scripts/copyCommitCommentToPrComment.js ${{ secrets.GITHUB_TOKEN }} ${{github.event.pull_request.head.sha}} ${{github.event.number}}
282+
- name: Compare benchmark result and fail if threshold is reached
283+
uses: benchmark-action/github-action-benchmark@v1
284+
with:
285+
# What benchmark tool the output.txt came from
286+
tool: 'benchmarkjs'
287+
# Where the output from the benchmark tool is stored
288+
output-file-path: benchmark-data.txt
289+
# Where the previous data file is stored
290+
external-data-json-path: web3-benchmark-main.json
291+
# Workflow will fail when an alert happens
292+
fail-on-alert: true
293+
# Enable alert commit comment
294+
alert-threshold: '100%'
295+
comment-always: false
296+
- name: Save main branch benchmark data
297+
uses: actions/cache/save@v3
298+
if: github.event_name == 'push' && github.ref == 'refs/heads/4.x'
299+
with:
300+
path: web3-benchmark-main.json
301+
key: ${{ runner.os }}-web3-benchmark-main.json

.github/workflows/deploy-docs.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Docs CloudFlare Deploy
2-
on:
2+
on:
33
push:
44
branches-ignore:
55
- "1.x"
@@ -25,4 +25,4 @@ jobs:
2525
accountId: 2238a825c5aca59233eab1f221f7aefb
2626
projectName: web3-js-docs
2727
directory: ./docs/build
28-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
28+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ tmp/
4242

4343
# Incubed (in3) nodelist
4444
packages/web3/.in3/
45+
46+
# benchmark results
47+
benchmark-data.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
label: 'Smart Contracts'
2+
collapsible: true
3+
collapsed: true
4+
link: null
5+
position: 4

docs/docs/guides/smart_contracts/deploying_and_interacting_with_smart_contracts.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 1
3-
sidebar_label: 'Deploying and Interacting with Smart Contracts'
3+
sidebar_label: 'Tutorial: Deploying and Interacting with Smart Contracts'
44
---
55

66
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:
2424
6. Deploy the smart contract to the Ganache network using web3.js.
2525
7. Interact with the smart contract using web3.js.
2626

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+
2733
## Step 1: Setting up the Environment
2834

2935
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
108114
// This code will compile smart contract and generate its ABI and bytecode
109115
// Alternatively, you can use something like `npm i solc && npx solcjs MyContract.sol --bin --abi`
110116

111-
import solc from 'solc';
112-
import path from 'path';
113-
import fs from 'fs';
117+
const solc = require( 'solc');
118+
const path = require('path');
119+
const fs = require('fs');
114120

115121
const fileName = 'MyContract.sol';
116122
const contractName = 'MyContract';
@@ -340,20 +346,20 @@ async function deploy() {
340346
const defaultAccount = providersAccounts[0];
341347
console.log('deployer account:', defaultAccount);
342348

343-
const deployedContract = myContract.deploy({
349+
const contractDeployer = myContract.deploy({
344350
data: '0x' + bytecode,
345351
arguments: [1],
346352
});
347353

348354
// optionally, estimate the gas that will be used for development and log it
349-
const gas = await deployedContract.estimateGas({
355+
const gas = await contractDeployer.estimateGas({
350356
from: defaultAccount,
351357
});
352358
console.log('estimated gas:', gas);
353359

354360
try {
355361
// Deploy the contract to the Ganache network
356-
const tx = await deployedContract.send({
362+
const tx = await contractDeployer.send({
357363
from: defaultAccount,
358364
gas,
359365
gasPrice: 10000000000,
@@ -396,18 +402,18 @@ async function deploy(): Promise<void> {
396402
const defaultAccount: string = providersAccounts[0];
397403
console.log('deployer account:', defaultAccount);
398404

399-
const deployedContract: any = myContract.deploy({
405+
const contractDeployer: any = myContract.deploy({
400406
data: '0x' + bytecode,
401407
arguments: [1],
402408
});
403409

404-
const gas: number = await deployedContract.estimateGas({
410+
const gas: number = await contractDeployer.estimateGas({
405411
from: defaultAccount,
406412
});
407413
console.log('estimated gas:', gas);
408414

409415
try {
410-
const tx: any = await deployedContract.send({
416+
const tx: any = await contractDeployer.send({
411417
from: defaultAccount,
412418
gas,
413419
gasPrice: 10000000000,

0 commit comments

Comments
 (0)