From e2cd083f38178e9ff7230e8bde0864be113bc24b Mon Sep 17 00:00:00 2001 From: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Fri, 29 Mar 2024 04:09:15 +0100 Subject: [PATCH] add solidity code sample --- .../guides/smart_contracts/tips_and_tricks.md | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/docs/guides/smart_contracts/tips_and_tricks.md b/docs/docs/guides/smart_contracts/tips_and_tricks.md index 23830625eb5..bcc98a2f7d4 100644 --- a/docs/docs/guides/smart_contracts/tips_and_tricks.md +++ b/docs/docs/guides/smart_contracts/tips_and_tricks.md @@ -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';