Skip to content

Commit

Permalink
fix(docs): contract-tutorial-hardhat-node (#7076)
Browse files Browse the repository at this point in the history
* Contract Tutorial Fixes

- Ganache has been deprecated, use Hardhat
- Use JavaScript instead of TypeScript
- Improvements (more links, formatting/consistency) and simplifications

* Hardhat node can use default automine behavior

* Remove private keys
  • Loading branch information
danforbes authored Jun 5, 2024
1 parent 1b1049d commit 9fe4eb2
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 269 deletions.
2 changes: 1 addition & 1 deletion docs/docs/guides/getting_started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_label: Introduction

Web3.js is a robust and flexible collection of **TypeScript and JavaScript** libraries that allows developers to interact with local or remote [Ethereum](https://ethereum.org/en/) nodes (or **any EVM-compatible blockchain**) over **HTTP, IPC or WebSocket** connections. It is a powerful and efficient toolkit for crafting applications within the Ethereum ecosystem and beyond.

This documentation is the entrypoint to Web3.js for developers. It covers [basic](/guides/getting_started/quickstart) and [advanced](/guides/smart_contracts/) usage with examples, and includes comprehensive [API documentation](/api) as well as guides for common tasks, like [upgrading](/guides/web3_upgrade_guide/x/) from older versions.
This documentation is the entrypoint to Web3.js for developers. It covers [basic](/guides/getting_started/quickstart) and [advanced](/guides/smart_contracts/mastering_smart_contracts) usage with examples, and includes comprehensive [API documentation](/api) as well as guides for common tasks, like [upgrading](/guides/web3_upgrade_guide/x/) from older versions.

## Features of Web3.js v4

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 1
sidebar_position: 2
sidebar_label: 'Mastering Smart Contracts'
---
# Mastering Smart Contracts
Expand Down Expand Up @@ -103,7 +103,7 @@ When you instantiate a `Contract`, you primarily provide one or two parameters,
1. **ABI (Application Binary Interface):** The ABI tells the `Contract` how to format calls and transactions so that the contract can understand them.

:::tip
If you do not know how to get the contract ABI, we recommend you to check the Step 4 at the [# Step 4: Deploying and Interacting with Smart Contracts](./smart_contracts_guide/#step-4-compile-the-solidity-code-using-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial. And to look into the guide: [Infer Contract Types from JSON Artifact](./infer_contract_types).
If you do not know how to get the contract ABI, we recommend you to check the Step 4 at the [# Step 4: Deploying and Interacting with Smart Contracts](./smart_contracts_guide#step-4-compile-the-solidity-code-with-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial. And to look into the guide: [Infer Contract Types from JSON Artifact](./infer_contract_types).
:::

2. (optional) **Contract Address:** The Ethereum address at which your contract is deployed. If the contract is not deployed yet, do not pass a second parameter or pass `undefined` to it.
Expand Down Expand Up @@ -274,7 +274,7 @@ console.log('Contract deployed at address: ' + tx.options.address);
```

:::tip
If you do not know how to get the contract bytecode, we recommend you to check the Step 4 at the [Deploying and Interacting with Smart Contracts](./smart_contracts_guide#step-4-compile-the-solidity-code-using-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial.
If you do not know how to get the contract bytecode, we recommend you to check the Step 4 at the [Deploying and Interacting with Smart Contracts](./smart_contracts_guide#step-4-compile-the-solidity-code-with-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial.
:::

- **getPastEvents**: Gets past events for this contract. It differs from `events` properties that it returns the past events as an array, rather than allowing to subscribe to them like when using `events` properties. More on the [API documentation](/api/web3-eth-contract/class/Contract#getPastEvents)
Expand Down Expand Up @@ -351,7 +351,7 @@ const bytecode = '0x60806040523480156100115760006000fd5b506040516102243803806102

:::info
And as mentioned in the tips inside previous sections:
If you do not know how to get the contract ABI and bytecode, we recommend you to check the Step 4 at the [Deploying and Interacting with Smart Contracts](./smart_contracts_guide#step-4-compile-the-solidity-code-using-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial.
If you do not know how to get the contract ABI and bytecode, we recommend you to check the Step 4 at the [Deploying and Interacting with Smart Contracts](./smart_contracts_guide#step-4-compile-the-solidity-code-with-the-solidity-compiler-and-get-its-abi-and-bytecode) tutorial.
:::

### Do I always need the contract ByteCode?
Expand Down
Loading

1 comment on commit 9fe4eb2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 9fe4eb2 Previous: 1b1049d Ratio
processingTx 8980 ops/sec (±4.80%) 9151 ops/sec (±3.87%) 1.02
processingContractDeploy 38804 ops/sec (±6.95%) 38199 ops/sec (±8.00%) 0.98
processingContractMethodSend 20527 ops/sec (±4.43%) 18831 ops/sec (±7.05%) 0.92
processingContractMethodCall 40756 ops/sec (±6.35%) 37775 ops/sec (±5.08%) 0.93
abiEncode 44494 ops/sec (±8.23%) 43128 ops/sec (±7.05%) 0.97
abiDecode 30658 ops/sec (±7.47%) 30542 ops/sec (±6.35%) 1.00
sign 1598 ops/sec (±0.76%) 1512 ops/sec (±3.92%) 0.95
verify 375 ops/sec (±0.38%) 367 ops/sec (±0.55%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.