diff --git a/fixtures/build/GreeterWithOverloading.json b/fixtures/build/GreeterWithOverloading.json
new file mode 100644
index 00000000000..8f85cee2c6c
--- /dev/null
+++ b/fixtures/build/GreeterWithOverloading.json
@@ -0,0 +1,125 @@
+{
+ "abi": [
+ {
+ "inputs": [
+ {
+ "internalType": "string",
+ "name": "_greeting",
+ "type": "string"
+ }
+ ],
+ "stateMutability": "nonpayable",
+ "type": "constructor"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "internalType": "string",
+ "name": "greeting",
+ "type": "string"
+ }
+ ],
+ "name": "GREETING_CHANGED",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "internalType": "string",
+ "name": "from",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "internalType": "string",
+ "name": "to",
+ "type": "string"
+ }
+ ],
+ "name": "GREETING_CHANGING",
+ "type": "event"
+ },
+ {
+ "inputs": [],
+ "name": "greet",
+ "outputs": [
+ {
+ "internalType": "string",
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "increment",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "string",
+ "name": "_greeting",
+ "type": "string"
+ },
+ {
+ "internalType": "bool",
+ "name": "_raiseEvents",
+ "type": "bool"
+ }
+ ],
+ "name": "setGreeting",
+ "outputs": [
+ {
+ "internalType": "bool",
+ "name": "",
+ "type": "bool"
+ },
+ {
+ "internalType": "string",
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "string",
+ "name": "_greeting",
+ "type": "string"
+ }
+ ],
+ "name": "setGreeting",
+ "outputs": [
+ {
+ "internalType": "bool",
+ "name": "",
+ "type": "bool"
+ },
+ {
+ "internalType": "string",
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }
+ ],
+ "evm": {
+ "bytecode": {
+ "object": "608060405234801562000010575f80fd5b506040516200104d3803806200104d8339818101604052810190620000369190620001da565b806001908162000047919062000460565b505f80819055505062000544565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000b6826200006e565b810181811067ffffffffffffffff82111715620000d857620000d76200007e565b5b80604052505050565b5f620000ec62000055565b9050620000fa8282620000ab565b919050565b5f67ffffffffffffffff8211156200011c576200011b6200007e565b5b62000127826200006e565b9050602081019050919050565b5f5b838110156200015357808201518184015260208101905062000136565b5f8484015250505050565b5f620001746200016e84620000ff565b620000e1565b9050828152602081018484840111156200019357620001926200006a565b5b620001a084828562000134565b509392505050565b5f82601f830112620001bf57620001be62000066565b5b8151620001d18482602086016200015e565b91505092915050565b5f60208284031215620001f257620001f16200005e565b5b5f82015167ffffffffffffffff81111562000212576200021162000062565b5b6200022084828501620001a8565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200027857607f821691505b6020821081036200028e576200028d62000233565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620002f27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002b5565b620002fe8683620002b5565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f62000348620003426200033c8462000316565b6200031f565b62000316565b9050919050565b5f819050919050565b620003638362000328565b6200037b62000372826200034f565b848454620002c1565b825550505050565b5f90565b6200039162000383565b6200039e81848462000358565b505050565b5b81811015620003c557620003b95f8262000387565b600181019050620003a4565b5050565b601f8211156200041457620003de8162000294565b620003e984620002a6565b81016020851015620003f9578190505b620004116200040885620002a6565b830182620003a3565b50505b505050565b5f82821c905092915050565b5f620004365f198460080262000419565b1980831691505092915050565b5f62000450838362000425565b9150826002028217905092915050565b6200046b8262000229565b67ffffffffffffffff8111156200048757620004866200007e565b5b62000493825462000260565b620004a0828285620003c9565b5f60209050601f831160018114620004d6575f8415620004c1578287015190505b620004cd858262000443565b8655506200053c565b601f198416620004e68662000294565b5f5b828110156200050f57848901518255600182019150602085019450602081019050620004e8565b868310156200052f57848901516200052b601f89168262000425565b8355505b6001600288020188555050505b505050505050565b610afb80620005525f395ff3fe608060405234801561000f575f80fd5b506004361061004a575f3560e01c80634495ef8a1461004e578063a41368621461007f578063cfae3217146100b0578063d09de08a146100ce575b5f80fd5b61006860048036038101906100639190610545565b6100d8565b604051610076929190610628565b60405180910390f35b61009960048036038101906100949190610656565b610203565b6040516100a7929190610628565b60405180910390f35b6100b861031e565b6040516100c5919061069d565b60405180910390f35b6100d66103ae565b005b5f6060821561011c577f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001856040516101139291906107ad565b60405180910390a15b836001908161012b9190610976565b50821561016b577f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516101629190610a45565b60405180910390a15b60018080805461017a906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546101a6906106ea565b80156101f15780601f106101c8576101008083540402835291602001916101f1565b820191905f5260205f20905b8154815290600101906020018083116101d457829003601f168201915b50505050509050915091509250929050565b5f60607f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001846040516102389291906107ad565b60405180910390a1826001908161024f9190610976565b507f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516102809190610a45565b60405180910390a1600180808054610297906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546102c3906106ea565b801561030e5780601f106102e55761010080835404028352916020019161030e565b820191905f5260205f20905b8154815290600101906020018083116102f157829003601f168201915b5050505050905091509150915091565b60606001805461032d906106ea565b80601f0160208091040260200160405190810160405280929190818152602001828054610359906106ea565b80156103a45780601f1061037b576101008083540402835291602001916103a4565b820191905f5260205f20905b81548152906001019060200180831161038757829003601f168201915b5050505050905090565b60015f546103bc9190610a92565b5f81905550565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610422826103dc565b810181811067ffffffffffffffff82111715610441576104406103ec565b5b80604052505050565b5f6104536103c3565b905061045f8282610419565b919050565b5f67ffffffffffffffff82111561047e5761047d6103ec565b5b610487826103dc565b9050602081019050919050565b828183375f83830152505050565b5f6104b46104af84610464565b61044a565b9050828152602081018484840111156104d0576104cf6103d8565b5b6104db848285610494565b509392505050565b5f82601f8301126104f7576104f66103d4565b5b81356105078482602086016104a2565b91505092915050565b5f8115159050919050565b61052481610510565b811461052e575f80fd5b50565b5f8135905061053f8161051b565b92915050565b5f806040838503121561055b5761055a6103cc565b5b5f83013567ffffffffffffffff811115610578576105776103d0565b5b610584858286016104e3565b925050602061059585828601610531565b9150509250929050565b6105a881610510565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156105e55780820151818401526020810190506105ca565b5f8484015250505050565b5f6105fa826105ae565b61060481856105b8565b93506106148185602086016105c8565b61061d816103dc565b840191505092915050565b5f60408201905061063b5f83018561059f565b818103602083015261064d81846105f0565b90509392505050565b5f6020828403121561066b5761066a6103cc565b5b5f82013567ffffffffffffffff811115610688576106876103d0565b5b610694848285016104e3565b91505092915050565b5f6020820190508181035f8301526106b581846105f0565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061070157607f821691505b602082108103610714576107136106bd565b5b50919050565b5f819050815f5260205f209050919050565b5f8154610738816106ea565b61074281866105b8565b9450600182165f811461075c5760018114610772576107a4565b60ff1983168652811515602002860193506107a4565b61077b8561071a565b5f5b8381101561079c5781548189015260018201915060208101905061077d565b808801955050505b50505092915050565b5f6040820190508181035f8301526107c5818561072c565b905081810360208301526107d981846105f0565b90509392505050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261082c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107f1565b61083686836107f1565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61087a6108756108708461084e565b610857565b61084e565b9050919050565b5f819050919050565b61089383610860565b6108a761089f82610881565b8484546107fd565b825550505050565b5f90565b6108bb6108af565b6108c681848461088a565b505050565b5b818110156108e9576108de5f826108b3565b6001810190506108cc565b5050565b601f82111561092e576108ff8161071a565b610908846107e2565b81016020851015610917578190505b61092b610923856107e2565b8301826108cb565b50505b505050565b5f82821c905092915050565b5f61094e5f1984600802610933565b1980831691505092915050565b5f610966838361093f565b9150826002028217905092915050565b61097f826105ae565b67ffffffffffffffff811115610998576109976103ec565b5b6109a282546106ea565b6109ad8282856108ed565b5f60209050601f8311600181146109de575f84156109cc578287015190505b6109d6858261095b565b865550610a3d565b601f1984166109ec8661071a565b5f5b82811015610a13578489015182556001820191506020850194506020810190506109ee565b86831015610a305784890151610a2c601f89168261093f565b8355505b6001600288020188555050505b505050505050565b5f6020820190508181035f830152610a5d818461072c565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610a9c8261084e565b9150610aa78361084e565b9250828201905080821115610abf57610abe610a65565b5b9291505056fea2646970667358221220ca996f61ff5eed9f5836fc8d7c848be4c10bc5fff806ab49930b9c7947082dea64736f6c63430008140033"
+ }
+ }
+}
diff --git a/fixtures/build/GreeterWithOverloading.ts b/fixtures/build/GreeterWithOverloading.ts
new file mode 100644
index 00000000000..4c5dceb90d2
--- /dev/null
+++ b/fixtures/build/GreeterWithOverloading.ts
@@ -0,0 +1,136 @@
+/*
+This file is part of web3.js.
+
+web3.js is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+web3.js is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with web3.js. If not, see .
+*/
+export const GreeterWithOverloadingAbi = [
+ {
+ inputs: [
+ {
+ internalType: 'string',
+ name: '_greeting',
+ type: 'string',
+ },
+ ],
+ stateMutability: 'nonpayable',
+ type: 'constructor',
+ },
+ {
+ anonymous: false,
+ inputs: [
+ {
+ indexed: false,
+ internalType: 'string',
+ name: 'greeting',
+ type: 'string',
+ },
+ ],
+ name: 'GREETING_CHANGED',
+ type: 'event',
+ },
+ {
+ anonymous: false,
+ inputs: [
+ {
+ indexed: false,
+ internalType: 'string',
+ name: 'from',
+ type: 'string',
+ },
+ {
+ indexed: false,
+ internalType: 'string',
+ name: 'to',
+ type: 'string',
+ },
+ ],
+ name: 'GREETING_CHANGING',
+ type: 'event',
+ },
+ {
+ inputs: [],
+ name: 'greet',
+ outputs: [
+ {
+ internalType: 'string',
+ name: '',
+ type: 'string',
+ },
+ ],
+ stateMutability: 'view',
+ type: 'function',
+ },
+ {
+ inputs: [],
+ name: 'increment',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ type: 'function',
+ },
+ {
+ inputs: [
+ {
+ internalType: 'string',
+ name: '_greeting',
+ type: 'string',
+ },
+ {
+ internalType: 'bool',
+ name: '_raiseEvents',
+ type: 'bool',
+ },
+ ],
+ name: 'setGreeting',
+ outputs: [
+ {
+ internalType: 'bool',
+ name: '',
+ type: 'bool',
+ },
+ {
+ internalType: 'string',
+ name: '',
+ type: 'string',
+ },
+ ],
+ stateMutability: 'nonpayable',
+ type: 'function',
+ },
+ {
+ inputs: [
+ {
+ internalType: 'string',
+ name: '_greeting',
+ type: 'string',
+ },
+ ],
+ name: 'setGreeting',
+ outputs: [
+ {
+ internalType: 'bool',
+ name: '',
+ type: 'bool',
+ },
+ {
+ internalType: 'string',
+ name: '',
+ type: 'string',
+ },
+ ],
+ stateMutability: 'nonpayable',
+ type: 'function',
+ },
+] as const;
+export const GreeterWithOverloadingBytecode =
+ '608060405234801562000010575f80fd5b506040516200104d3803806200104d8339818101604052810190620000369190620001da565b806001908162000047919062000460565b505f80819055505062000544565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000b6826200006e565b810181811067ffffffffffffffff82111715620000d857620000d76200007e565b5b80604052505050565b5f620000ec62000055565b9050620000fa8282620000ab565b919050565b5f67ffffffffffffffff8211156200011c576200011b6200007e565b5b62000127826200006e565b9050602081019050919050565b5f5b838110156200015357808201518184015260208101905062000136565b5f8484015250505050565b5f620001746200016e84620000ff565b620000e1565b9050828152602081018484840111156200019357620001926200006a565b5b620001a084828562000134565b509392505050565b5f82601f830112620001bf57620001be62000066565b5b8151620001d18482602086016200015e565b91505092915050565b5f60208284031215620001f257620001f16200005e565b5b5f82015167ffffffffffffffff81111562000212576200021162000062565b5b6200022084828501620001a8565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200027857607f821691505b6020821081036200028e576200028d62000233565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620002f27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002b5565b620002fe8683620002b5565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f62000348620003426200033c8462000316565b6200031f565b62000316565b9050919050565b5f819050919050565b620003638362000328565b6200037b62000372826200034f565b848454620002c1565b825550505050565b5f90565b6200039162000383565b6200039e81848462000358565b505050565b5b81811015620003c557620003b95f8262000387565b600181019050620003a4565b5050565b601f8211156200041457620003de8162000294565b620003e984620002a6565b81016020851015620003f9578190505b620004116200040885620002a6565b830182620003a3565b50505b505050565b5f82821c905092915050565b5f620004365f198460080262000419565b1980831691505092915050565b5f62000450838362000425565b9150826002028217905092915050565b6200046b8262000229565b67ffffffffffffffff8111156200048757620004866200007e565b5b62000493825462000260565b620004a0828285620003c9565b5f60209050601f831160018114620004d6575f8415620004c1578287015190505b620004cd858262000443565b8655506200053c565b601f198416620004e68662000294565b5f5b828110156200050f57848901518255600182019150602085019450602081019050620004e8565b868310156200052f57848901516200052b601f89168262000425565b8355505b6001600288020188555050505b505050505050565b610afb80620005525f395ff3fe608060405234801561000f575f80fd5b506004361061004a575f3560e01c80634495ef8a1461004e578063a41368621461007f578063cfae3217146100b0578063d09de08a146100ce575b5f80fd5b61006860048036038101906100639190610545565b6100d8565b604051610076929190610628565b60405180910390f35b61009960048036038101906100949190610656565b610203565b6040516100a7929190610628565b60405180910390f35b6100b861031e565b6040516100c5919061069d565b60405180910390f35b6100d66103ae565b005b5f6060821561011c577f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001856040516101139291906107ad565b60405180910390a15b836001908161012b9190610976565b50821561016b577f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516101629190610a45565b60405180910390a15b60018080805461017a906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546101a6906106ea565b80156101f15780601f106101c8576101008083540402835291602001916101f1565b820191905f5260205f20905b8154815290600101906020018083116101d457829003601f168201915b50505050509050915091509250929050565b5f60607f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001846040516102389291906107ad565b60405180910390a1826001908161024f9190610976565b507f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516102809190610a45565b60405180910390a1600180808054610297906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546102c3906106ea565b801561030e5780601f106102e55761010080835404028352916020019161030e565b820191905f5260205f20905b8154815290600101906020018083116102f157829003601f168201915b5050505050905091509150915091565b60606001805461032d906106ea565b80601f0160208091040260200160405190810160405280929190818152602001828054610359906106ea565b80156103a45780601f1061037b576101008083540402835291602001916103a4565b820191905f5260205f20905b81548152906001019060200180831161038757829003601f168201915b5050505050905090565b60015f546103bc9190610a92565b5f81905550565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610422826103dc565b810181811067ffffffffffffffff82111715610441576104406103ec565b5b80604052505050565b5f6104536103c3565b905061045f8282610419565b919050565b5f67ffffffffffffffff82111561047e5761047d6103ec565b5b610487826103dc565b9050602081019050919050565b828183375f83830152505050565b5f6104b46104af84610464565b61044a565b9050828152602081018484840111156104d0576104cf6103d8565b5b6104db848285610494565b509392505050565b5f82601f8301126104f7576104f66103d4565b5b81356105078482602086016104a2565b91505092915050565b5f8115159050919050565b61052481610510565b811461052e575f80fd5b50565b5f8135905061053f8161051b565b92915050565b5f806040838503121561055b5761055a6103cc565b5b5f83013567ffffffffffffffff811115610578576105776103d0565b5b610584858286016104e3565b925050602061059585828601610531565b9150509250929050565b6105a881610510565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156105e55780820151818401526020810190506105ca565b5f8484015250505050565b5f6105fa826105ae565b61060481856105b8565b93506106148185602086016105c8565b61061d816103dc565b840191505092915050565b5f60408201905061063b5f83018561059f565b818103602083015261064d81846105f0565b90509392505050565b5f6020828403121561066b5761066a6103cc565b5b5f82013567ffffffffffffffff811115610688576106876103d0565b5b610694848285016104e3565b91505092915050565b5f6020820190508181035f8301526106b581846105f0565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061070157607f821691505b602082108103610714576107136106bd565b5b50919050565b5f819050815f5260205f209050919050565b5f8154610738816106ea565b61074281866105b8565b9450600182165f811461075c5760018114610772576107a4565b60ff1983168652811515602002860193506107a4565b61077b8561071a565b5f5b8381101561079c5781548189015260018201915060208101905061077d565b808801955050505b50505092915050565b5f6040820190508181035f8301526107c5818561072c565b905081810360208301526107d981846105f0565b90509392505050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261082c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107f1565b61083686836107f1565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61087a6108756108708461084e565b610857565b61084e565b9050919050565b5f819050919050565b61089383610860565b6108a761089f82610881565b8484546107fd565b825550505050565b5f90565b6108bb6108af565b6108c681848461088a565b505050565b5b818110156108e9576108de5f826108b3565b6001810190506108cc565b5050565b601f82111561092e576108ff8161071a565b610908846107e2565b81016020851015610917578190505b61092b610923856107e2565b8301826108cb565b50505b505050565b5f82821c905092915050565b5f61094e5f1984600802610933565b1980831691505092915050565b5f610966838361093f565b9150826002028217905092915050565b61097f826105ae565b67ffffffffffffffff811115610998576109976103ec565b5b6109a282546106ea565b6109ad8282856108ed565b5f60209050601f8311600181146109de575f84156109cc578287015190505b6109d6858261095b565b865550610a3d565b601f1984166109ec8661071a565b5f5b82811015610a13578489015182556001820191506020850194506020810190506109ee565b86831015610a305784890151610a2c601f89168261093f565b8355505b6001600288020188555050505b505050505050565b5f6020820190508181035f830152610a5d818461072c565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610a9c8261084e565b9150610aa78361084e565b9250828201905080821115610abf57610abe610a65565b5b9291505056fea2646970667358221220ca996f61ff5eed9f5836fc8d7c848be4c10bc5fff806ab49930b9c7947082dea64736f6c63430008140033';
diff --git a/fixtures/contracts/GreeterWithOverloading.sol b/fixtures/contracts/GreeterWithOverloading.sol
new file mode 100644
index 00000000000..ca2a00dadd3
--- /dev/null
+++ b/fixtures/contracts/GreeterWithOverloading.sol
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GNU
+
+pragma solidity ^0.8.13;
+
+contract GreeterWithOverloading {
+ uint256 counter;
+ string private greeting;
+
+ event GREETING_CHANGING(string from, string to);
+ event GREETING_CHANGED(string greeting);
+
+ constructor(string memory _greeting) {
+ greeting = _greeting;
+ counter = 0;
+ }
+
+ function greet() public view returns (string memory) {
+ return greeting;
+ }
+
+ function setGreeting(string memory _greeting) public returns (bool, string memory) {
+ emit GREETING_CHANGING(greeting, _greeting);
+ greeting = _greeting;
+ emit GREETING_CHANGED(greeting);
+ return (true, greeting);
+ }
+
+ // function overlading with addtional parameter
+ function setGreeting(string memory _greeting, bool _raiseEvents) public returns (bool, string memory) {
+ if(_raiseEvents) {
+ emit GREETING_CHANGING(greeting, _greeting);
+ }
+ greeting = _greeting;
+ if(_raiseEvents) {
+ emit GREETING_CHANGED(greeting);
+ }
+ return (true, greeting);
+ }
+
+ function increment() public {
+ counter = counter + 1;
+ }
+}
+
\ No newline at end of file
diff --git a/packages/web3-eth-contract/test/unit/contract.test.ts b/packages/web3-eth-contract/test/unit/contract.test.ts
index 828666243a2..f721ab8936c 100644
--- a/packages/web3-eth-contract/test/unit/contract.test.ts
+++ b/packages/web3-eth-contract/test/unit/contract.test.ts
@@ -16,13 +16,18 @@ along with web3.js. If not, see .
*/
import * as eth from 'web3-eth';
-import { ValidChains, Hardfork, AccessListResult, Address, ETH_DATA_FORMAT } from 'web3-types';
+import { ValidChains, Hardfork, AccessListResult, Address, ETH_DATA_FORMAT , DEFAULT_RETURN_FORMAT } from 'web3-types';
import { Web3ContractError } from 'web3-errors';
-import { Web3Context } from 'web3-core';
+import { Web3Context , Web3ConfigEvent } from 'web3-core';
+import { Web3ValidatorError } from 'web3-validator';
import { Contract } from '../../src';
import { sampleStorageContractABI } from '../fixtures/storage';
import { GreeterAbi, GreeterBytecode } from '../shared_fixtures/build/Greeter';
+import {
+ GreeterWithOverloadingAbi,
+ GreeterWithOverloadingBytecode,
+} from '../shared_fixtures/build/GreeterWithOverloading';
import { AllGetPastEventsData, getLogsData, getPastEventsData } from '../fixtures/unitTestFixtures';
import { getSystemTestProvider } from '../fixtures/system_test_utils';
import { erc721Abi } from '../fixtures/erc721';
@@ -340,6 +345,131 @@ describe('Contract', () => {
spyTx.mockClear();
});
+ it('test calling overloaded solidity method', async () => {
+ const arg = 'Hello';
+ const contract = new Contract(GreeterWithOverloadingAbi);
+ sendOptions = {
+ from: '0x12364916b10Ae90076dDa6dE756EE1395BB69ec2',
+ gas: '1000000',
+ };
+ const spyTx = jest
+ .spyOn(eth, 'sendTransaction')
+ .mockImplementation((_objInstance, _tx) => {
+ const newContract = contract.clone();
+ newContract.options.address = deployedAddr;
+ expect(_tx.data).toBeDefined();
+ if (
+ _tx.data ===
+ '0xa41368620000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000' ||
+ _tx.data ===
+ '0x4495ef8a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000'
+ ) {
+ // eslint-disable-next-line
+ expect(_tx.to).toStrictEqual(deployedAddr);
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-empty-function
+ return { status: '0x1', on: () => {} } as any;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-empty-function
+ return Object.assign(Promise.resolve(newContract), { on: () => {} }) as any;
+ });
+
+ const deployedContract = await contract
+ .deploy({
+ data: GreeterWithOverloadingBytecode,
+ arguments: ['My Greeting'],
+ })
+ .send(sendOptions);
+
+ const receipt = await deployedContract.methods.setGreeting(arg).send(sendOptions);
+ expect(receipt.status).toBe('0x1');
+
+ const receipt2 = await deployedContract.methods
+ .setGreeting(arg, true)
+ .send(sendOptions);
+ expect(receipt2.status).toBe('0x1');
+
+ spyTx.mockClear();
+ });
+
+ it('test calling overloaded solidity method with incompatible parameters', async () => {
+ const arg = 'Hello';
+ const contract = new Contract(GreeterWithOverloadingAbi);
+ sendOptions = {
+ from: '0x12364916b10Ae90076dDa6dE756EE1395BB69ec2',
+ gas: '1000000',
+ };
+ const spyTx = jest
+ .spyOn(eth, 'sendTransaction')
+ .mockImplementation((_objInstance, _tx) => {
+ const newContract = contract.clone();
+ newContract.options.address = deployedAddr;
+ expect(_tx.data).toBeDefined();
+ if (
+ _tx.data ===
+ '0xa41368620000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000' ||
+ _tx.data ===
+ '0x4495ef8a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000'
+ ) {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(_tx.to).toStrictEqual(deployedAddr);
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-empty-function
+ return { status: '0x1', on: () => {} } as any;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-empty-function
+ return Object.assign(Promise.resolve(newContract), { on: () => {} }) as any;
+ });
+
+ const deployedContract = await contract
+ .deploy({
+ data: GreeterWithOverloadingBytecode,
+ arguments: ['My Greeting'],
+ })
+ .send(sendOptions);
+
+ const receipt = await deployedContract.methods.setGreeting(arg).send(sendOptions);
+ expect(receipt.status).toBe('0x1');
+
+ // calling with correct parameters should pass
+ const receipt2 = await deployedContract.methods
+ .setGreeting(arg, true)
+ .send(sendOptions);
+ expect(receipt2.status).toBe('0x1');
+
+ // calling with wrong parameters should throw
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
+ await(deployedContract.methods.setGreeting as any)(arg, 'test').send(sendOptions);
+ expect(true).toBe(false);
+ } catch (error) {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(error).toBeInstanceOf(Web3ValidatorError);
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect((error as Web3ValidatorError).message).toBe(
+ 'Web3 validator found 1 error[s]:\nWeb3 validator found 1 error[s]:\nvalue "test" at "/1" must pass "bool" validation',
+ );
+ }
+
+ // calling with wrong parameters should throw
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
+ await(deployedContract.methods.setGreeting as any)(arg, true, 'test').send(
+ sendOptions,
+ );
+ expect(true).toBe(false);
+ } catch (error) {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(error).toBeInstanceOf(Web3ValidatorError);
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect((error as Web3ValidatorError).message).toBe(
+ 'Web3 validator found 1 error[s]:\nmust NOT have more than 1 items',
+ );
+ }
+
+ spyTx.mockClear();
+ });
+
it('send method on deployed contract should work using data (default)', async () => {
const arg = 'Hello';
const contract = new Contract(GreeterAbi);
@@ -380,6 +510,24 @@ describe('Contract', () => {
spyTx.mockClear();
});
+ it('should config change if the linked web3config emitted a config change event', async () => {
+ const expectedProvider = 'http://127.0.0.1:8545';
+ const web3Context = new Web3Context({
+ provider: expectedProvider,
+ config: {
+ contractDataInputFill: 'data',
+ defaultAccount: '0x00000000219ab540356cBB839Cbe05303d7705Fa',
+ },
+ });
+ const contract = new Contract(GreeterAbi, web3Context);
+ web3Context.emit(Web3ConfigEvent.CONFIG_CHANGE, {
+ name: 'contractDataInputFill',
+ oldValue: 'data',
+ newValue: 'input',
+ });
+ expect(contract.config.contractDataInputFill).toBe('input');
+ });
+
it('should send method on deployed contract should work with data using web3config', async () => {
const expectedProvider = 'http://127.0.0.1:8545';
const web3Context = new Web3Context({
@@ -1176,6 +1324,42 @@ describe('Contract', () => {
spyTx.mockClear();
});
+ it.skip('estimateGas should use DEFAULT_RETURN_FORMAT by default', async () => {
+ const contract = new Contract(GreeterAbi);
+
+ const spyTx = jest.spyOn(eth, 'sendTransaction').mockImplementation(() => {
+ const newContract = contract.clone();
+ newContract.options.address = deployedAddr;
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
+ return Promise.resolve(newContract) as any;
+ });
+
+ const spyEstimateGas = jest
+ .spyOn(eth, 'estimateGas')
+ .mockImplementationOnce(async (_objInstance, _tx, _block, returnFormat) => {
+ expect(_block).toBe('latest');
+ expect(_tx.to).toBeUndefined();
+ expect(_tx.from).toStrictEqual(sendOptions.from);
+ expect(_tx.input).toBe(
+ '0x60806040523480156200001157600080fd5b5060405162000ed038038062000ed08339818101604052810190620000379190620001ea565b806001908162000048919062000486565b5060008081905550506200056d565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620000c08262000075565b810181811067ffffffffffffffff82111715620000e257620000e162000086565b5b80604052505050565b6000620000f762000057565b9050620001058282620000b5565b919050565b600067ffffffffffffffff82111562000128576200012762000086565b5b620001338262000075565b9050602081019050919050565b60005b838110156200016057808201518184015260208101905062000143565b60008484015250505050565b6000620001836200017d846200010a565b620000eb565b905082815260208101848484011115620001a257620001a162000070565b5b620001af84828562000140565b509392505050565b600082601f830112620001cf57620001ce6200006b565b5b8151620001e18482602086016200016c565b91505092915050565b60006020828403121562000203576200020262000061565b5b600082015167ffffffffffffffff81111562000224576200022362000066565b5b6200023284828501620001b7565b91505092915050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200028e57607f821691505b602082108103620002a457620002a362000246565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026200030e7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002cf565b6200031a8683620002cf565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000367620003616200035b8462000332565b6200033c565b62000332565b9050919050565b6000819050919050565b620003838362000346565b6200039b62000392826200036e565b848454620002dc565b825550505050565b600090565b620003b2620003a3565b620003bf81848462000378565b505050565b5b81811015620003e757620003db600082620003a8565b600181019050620003c5565b5050565b601f82111562000436576200040081620002aa565b6200040b84620002bf565b810160208510156200041b578190505b620004336200042a85620002bf565b830182620003c4565b50505b505050565b600082821c905092915050565b60006200045b600019846008026200043b565b1980831691505092915050565b600062000476838362000448565b9150826002028217905092915050565b62000491826200023b565b67ffffffffffffffff811115620004ad57620004ac62000086565b5b620004b9825462000275565b620004c6828285620003eb565b600060209050601f831160018114620004fe5760008415620004e9578287015190505b620004f5858262000468565b86555062000565565b601f1984166200050e86620002aa565b60005b82811015620005385784890151825560018201915060208501945060208101905062000511565b8683101562000558578489015162000554601f89168262000448565b8355505b6001600288020188555050505b505050505050565b610953806200057d6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063a413686214610046578063cfae321714610077578063d09de08a14610095575b600080fd5b610060600480360381019061005b91906103c0565b61009f565b60405161006e9291906104a3565b60405180910390f35b61007f6101bd565b60405161008c91906104d3565b60405180910390f35b61009d61024f565b005b600060607f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001846040516100d59291906105ee565b60405180910390a182600190816100ec91906107c6565b507f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e600160405161011d9190610898565b60405180910390a160018080805461013490610524565b80601f016020809104026020016040519081016040528092919081815260200182805461016090610524565b80156101ad5780601f10610182576101008083540402835291602001916101ad565b820191906000526020600020905b81548152906001019060200180831161019057829003601f168201915b5050505050905091509150915091565b6060600180546101cc90610524565b80601f01602080910402602001604051908101604052809291908181526020018280546101f890610524565b80156102455780601f1061021a57610100808354040283529160200191610245565b820191906000526020600020905b81548152906001019060200180831161022857829003601f168201915b5050505050905090565b600160005461025e91906108e9565b600081905550565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6102cd82610284565b810181811067ffffffffffffffff821117156102ec576102eb610295565b5b80604052505050565b60006102ff610266565b905061030b82826102c4565b919050565b600067ffffffffffffffff82111561032b5761032a610295565b5b61033482610284565b9050602081019050919050565b82818337600083830152505050565b600061036361035e84610310565b6102f5565b90508281526020810184848401111561037f5761037e61027f565b5b61038a848285610341565b509392505050565b600082601f8301126103a7576103a661027a565b5b81356103b7848260208601610350565b91505092915050565b6000602082840312156103d6576103d5610270565b5b600082013567ffffffffffffffff8111156103f4576103f3610275565b5b61040084828501610392565b91505092915050565b60008115159050919050565b61041e81610409565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561045e578082015181840152602081019050610443565b60008484015250505050565b600061047582610424565b61047f818561042f565b935061048f818560208601610440565b61049881610284565b840191505092915050565b60006040820190506104b86000830185610415565b81810360208301526104ca818461046a565b90509392505050565b600060208201905081810360008301526104ed818461046a565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061053c57607f821691505b60208210810361054f5761054e6104f5565b5b50919050565b60008190508160005260206000209050919050565b6000815461057781610524565b610581818661042f565b9450600182166000811461059c57600181146105b2576105e5565b60ff1983168652811515602002860193506105e5565b6105bb85610555565b60005b838110156105dd578154818901526001820191506020810190506105be565b808801955050505b50505092915050565b60006040820190508181036000830152610608818561056a565b9050818103602083015261061c818461046a565b90509392505050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026106727fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610635565b61067c8683610635565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006106c36106be6106b984610694565b61069e565b610694565b9050919050565b6000819050919050565b6106dd836106a8565b6106f16106e9826106ca565b848454610642565b825550505050565b600090565b6107066106f9565b6107118184846106d4565b505050565b5b818110156107355761072a6000826106fe565b600181019050610717565b5050565b601f82111561077a5761074b81610555565b61075484610625565b81016020851015610763578190505b61077761076f85610625565b830182610716565b50505b505050565b600082821c905092915050565b600061079d6000198460080261077f565b1980831691505092915050565b60006107b6838361078c565b9150826002028217905092915050565b6107cf82610424565b67ffffffffffffffff8111156107e8576107e7610295565b5b6107f28254610524565b6107fd828285610739565b600060209050601f831160018114610830576000841561081e578287015190505b61082885826107aa565b865550610890565b601f19841661083e86610555565b60005b8281101561086657848901518255600182019150602085019450602081019050610841565b86831015610883578489015161087f601f89168261078c565b8355505b6001600288020188555050505b505050505050565b600060208201905081810360008301526108b2818461056a565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108f482610694565b91506108ff83610694565b9250828201905080821115610917576109166108ba565b5b9291505056fea26469706673582212207e5ba44159ffb37af8e8a9e7c5b6fb5ce81ea195b62ae3ac36288f2cf72c18a764736f6c634300081000330000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b4d79204772656574696e67000000000000000000000000000000000000000000',
+ );
+ expect(returnFormat).toBe(DEFAULT_RETURN_FORMAT);
+
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
+ return Promise.resolve(BigInt(36916));
+ });
+
+ const deploy = contract.deploy({
+ input: GreeterBytecode,
+ arguments: ['My Greeting'],
+ });
+
+ const result = await deploy.estimateGas(sendOptions);
+ expect(result).toStrictEqual(BigInt(36916));
+
+ spyTx.mockClear();
+ spyEstimateGas.mockClear();
+ });
it('estimateGas should work for the deploy function using input', async () => {
const contract = new Contract(GreeterAbi);