Skip to content

Commit

Permalink
add solidity code sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad-Altabba committed Mar 29, 2024
1 parent 2ef38de commit e2cd083
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion docs/docs/guides/smart_contracts/tips_and_tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,30 @@ Parameter overloading enables smart contracts to define multiple functions beari

### Example Code

Below is a demonstration of invoking two versions of the `funcWithParamsOverloading` function in a smart contract, differentiated by their parameter types`uint256` versus `address`.
Below is a demonstration of invoking two versions of the `funcWithParamsOverloading` function in a smart contract, differentiated by their parameter types: `uint256` versus `address`.

The Solidity code:

```solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.20 <0.9.0;
contract TestOverlading {
function funcWithParamsOverloading(uint256 userId) public pure returns (string memory) {
return "called for the parameter with the type 'uint256'";
}
function funcWithParamsOverloading(address userAddress) public pure returns (string memory) {
return "called for the parameter with the type 'address'";
}
}
```

The TypeScript:
```typescript
import { Web3 } from 'web3';

Expand Down

1 comment on commit e2cd083

@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: e2cd083 Previous: 6c075db Ratio
processingTx 9129 ops/sec (±3.98%) 9301 ops/sec (±4.81%) 1.02
processingContractDeploy 40399 ops/sec (±6.97%) 39129 ops/sec (±7.62%) 0.97
processingContractMethodSend 18263 ops/sec (±9.84%) 19443 ops/sec (±5.19%) 1.06
processingContractMethodCall 37486 ops/sec (±5.54%) 38971 ops/sec (±6.34%) 1.04
abiEncode 42734 ops/sec (±7.02%) 44252 ops/sec (±6.92%) 1.04
abiDecode 28094 ops/sec (±7.07%) 30419 ops/sec (±8.89%) 1.08
sign 1621 ops/sec (±0.60%) 1656 ops/sec (±4.08%) 1.02
verify 372 ops/sec (±0.51%) 373 ops/sec (±0.78%) 1.00

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

Please sign in to comment.