Skip to content

Commit

Permalink
added live code editor to mastering smart contracts with contract sam…
Browse files Browse the repository at this point in the history
…ple (#6893)
  • Loading branch information
SantiagoDevRel authored Mar 14, 2024
1 parent 383af39 commit 16a2c27
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions docs/docs/guides/smart_contracts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,40 @@
sidebar_position: 1
sidebar_label: 'Mastering Smart Contracts'
---

# Mastering Smart Contracts

## Live code editor

### Deploy and Interact with smart contracts:

This contract is deployed on the [mumbai testnet](https://mumbai.polygonscan.com/address/0xB9433C87349134892f6C9a9E342Ed6adce39F8dF). In this live code editor, you will find the following:

In the code editor you'll find:
- `ContractCounter.sol`: the solidity code of the contract with:
- `uint256 number`: state variable of the contract.
- `increase()`: this function will increment by 1 the `number` variable.
- `getNumber()`: this function will return the current value of the `number` variable.
- `counterABI.json`: the ABI of the ContractCounter.sol
- `counterBytecode.json`: the compiled Bytecode of the ContractCounter.sol
- `main.js`: here you will find 3 funtions:
- `deploy()`: sample script to deploy the smart contract using the ABI and Bytecode
- `getNumber()`: sample script to call the reading function getNumber() of the smart contract
- `increase()`: sample script to interact with the increase() function of the smart contract

- Contract address:
```bash
0xB9433C87349134892f6C9a9E342Ed6adce39F8dF
```

<iframe width="100%" height="700px" src="https://stackblitz.com/edit/vitejs-vite-idcw5t?embed=1&file=main.js&showSidebar=1"></iframe>


## Contract class

:::info
This guide expects you to have some basic knowledge. If you are just starting, it is recommended to first check out this [Tutorial: Deploying and Interacting with Smart Contracts](./smart_contracts_guide.md).
:::

## Contract class

The `Contract` class is the main object exported by the `web3-eth-contract` package. It is also available in the `web3` package.

### Importing the Contract Class
Expand Down

1 comment on commit 16a2c27

@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: 16a2c27 Previous: 6c075db Ratio
processingTx 9698 ops/sec (±3.67%) 9301 ops/sec (±4.81%) 0.96
processingContractDeploy 41222 ops/sec (±7.52%) 39129 ops/sec (±7.62%) 0.95
processingContractMethodSend 21355 ops/sec (±5.77%) 19443 ops/sec (±5.19%) 0.91
processingContractMethodCall 42136 ops/sec (±4.87%) 38971 ops/sec (±6.34%) 0.92
abiEncode 48825 ops/sec (±5.90%) 44252 ops/sec (±6.92%) 0.91
abiDecode 34546 ops/sec (±8.11%) 30419 ops/sec (±8.89%) 0.88
sign 1646 ops/sec (±3.74%) 1656 ops/sec (±4.08%) 1.01
verify 383 ops/sec (±0.40%) 373 ops/sec (±0.78%) 0.97

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

Please sign in to comment.