Cannot access member 'match' of undefined in geth - ethereum

I am testing with rinkiby in ethereum geth environment (using light node.). By building the contract with solidity, the contract has been deployed correctly. If I try to access a function in that instance, I got a "match" error. I don't use "match" anywhere in the program source code, but I don't know which part is the problem. Can I analyze more solidity code?

Upgrade your web3 version.
reference.

Related

Why would create2 revert?

I'm debugging a reverted transaction on Polygon and this is all the information I have: https://mumbai.polygonscan.com/tx/0xfa86dc4957e3a3da9298b7672b11a20ebe921854fa494dc073920c067c1e693f#internal
If I'm reading it correctly, it seems to be saying that a CREATE2 reverted. But what are some reasons why a CREATE2 can revert? I'm aware that it would revert if something already existed at the address, but this isn't the case here, as you can see from here: https://mumbai.polygonscan.com/address/0x6bb03ca906c0372f384b845bd5ce9ca4327ffbe6
The linked transaction makes a message call (aka internal transaction) to contract deployed at 0x1079b7398b6efd9845c4db079e6fac8d21cf67b3.
This 0x1079b7... contract then tries to deploy a new contract on address 0x6bb03ca906c0372f384b845bd5ce9ca4327ffbe6, you can see the bytecode of the new contract for example in the Tenderly debugger.
As far as I'm aware, create2 can revert for 3 reasons:
Not enough gas left to perform the deployment
Not an issue in this case. Acording to the debugger there was ~9M gas units left and the deployment would take only ~1M gas units.
Deploying contract to address where another contract instance is already deployed.
Because you can predetermine the contract address with create2, this can happen. However not in this case either, the 0x6bb03c... address is empty, there's no contract deployed.
So we're left with uncaught exception during executing the constructor.
pragma solidity ^0.8;
contract MyContract {
constructor() {
require(false);
}
}
A code like this fails the deployment and effectively causes the create2 code to revert.
Unfortunately, without the new contract source code, it's hard to tell what exactly is the cause of constructor revert. Whether it's unexpected length or input params to the constructor, logical error, trying to make a call to non-existing contract, or anything else.
It turns out that I'm misreading Polygonscan and that just because there's a red mark next to an internal transaction doesn't mean that it's the internal transaction itself that reverted; it means that the whole transaction reverted. Anyways, using the Tenderly debugger helped me identity the real bug.

Error! Unable to generate Contract ByteCode and ABI

I deployed a contract of a token that has up to nine other files imported to the finance blockchain. I have done everything I can read and try in order to verify it. But it keeps giving me error.
Compiler debug log:
Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code : Address, Context, IERC20, IUniswapV2Factory, IUniswapV2Pair, IUniswapV2Router01, IUniswapV2Router02, Ownable, RentCoin, SafeMath
But we were unable to locate a matching bytecode (err_code_2)
For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions
My contract was compiled and deployed using Remix and optimization was set to 200. My compiler version is 0.6.12 and the link to the flattened contract is below:
https://drive.google.com/file/d/100J73q4hutqqmT1tZEuMn46YYFmzYaT0/view?usp=sharing
I understand that this contract involves constructors but I really need a practical guide on how to locate them and convert them to the right-abi-encoded JSON format that the verification page may accept.

Solidity - What version of the contract do I deploy?

I am currently learning Solidity and I have made my first BSC test contract with no errors. I have compiled my contract successfully and I am now in the deployment section of Remix.
There is a drop down menu named "contract" and within there, there are the following options:
test.sol...ApproveAndCallFallback
test.sol...BEP20Interface
test.sol...Owned
test.sol...SafeMath
test.sol...TokenBEP20
test.sol...
I am a bit confused as to which I actually deploy for my contract as there are multiple options. Could someone please point me in the right direction for descriptions of these options?
Thanks!
In the contract selectbox, you select the main contract that you want to deploy.
Most likely you have written the TokenBEP20 token and it's going to be the TokenBEP20, but it all depends on your context.

Verify and Publish Contract on Etherscan with Imported OpenZeppelin file

I'm currently building a ERC721 compliant contract and have published the contract here: https://ropsten.etherscan.io/address/0xa513bc0a0d3af384fefcd8bbc1cc0c9763307c39 - I'm now attempting to verify and publish the contract source code
The start of my file looks like so:
// SPDX-License-Identifier: MIT
// We will be using Solidity version 0.8.4
pragma solidity 0.8.4;
import "#openzeppelin/contracts/token/ERC721/ERC721.sol";
contract ViperToken is ERC721 {
However, when attempting to verify and publish with a Solidity single file I have the following error appear:
ParserError: Source "#openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported
--> myc:6:1:
|
6 | import "#openzeppelin/contracts/token/ERC721/ERC721.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can anyone point me in the direction to either 1. Solve this problem or 2. Documentation on how to appropriately write a contract that has dependencies imported that can be verified with Etherscan. Right now this is just a single file contract.
Simply put I had to go down a rabbit hole to work this out as I'm pretty new to Solidity.
I had to do the following;
Learn and use https://www.trufflesuite.com/ to setup a project and put my contract there (Using Ganache helped a lot with testing for anyone new to Solidity too)
Use HD Wallet provider package and follow tutorial here to get it on ropsten Etherscan https://medium.com/coinmonks/5-minute-guide-to-deploying-smart-contracts-with-truffle-and-ropsten-b3e30d5ee1e
Finally, use truffle-plugin-verify https://github.com/rkalis/truffle-plugin-verify to verify the contract on Etherscan
All in all, I am pretty sure there is no way within the Etherscan web app to verify a contract that contains an imported file.
The final product is here if anyone is interested in seeing how I structured it all https://github.com/lukecurtis93/viper-nft (it's just a CryptoKitties clone I found online as a base and updated it all)
If you are compiling into REMIX IDE
From REMIX IDE
Search for "Flattener" pluging
RIght click the file -> Flatten yourcontract.sol
Copy/Paste on Etherscan
I used npx hardhat flatten to compile all the code into one page, then copy and paste the code into Etherscan's single file verification. I think it is fine if you are just learning to get a feel for verifying your smart contract in Etherscan. But when it comes to production level code, I think OP's solution is better.
npx hardhat flatten gives license identifiers error when trying to verify in etherscan.
Solution is to add the below in hardhat.config.js
task("flat", "Flattens and prints contracts and their dependencies (Resolves licenses)")
.addOptionalVariadicPositionalParam("files", "The files to flatten", undefined, types.inputFile)
.setAction(async ({ files }, hre) => {
let flattened = await hre.run("flatten:get-flattened-sources", { files });
// Remove every line started with "// SPDX-License-Identifier:"
flattened = flattened.replace(/SPDX-License-Identifier:/gm, "License-Identifier:");
flattened = `// SPDX-License-Identifier: MIXED\n\n${flattened}`;
// Remove every line started with "pragma experimental ABIEncoderV2;" except the first one
flattened = flattened.replace(/pragma experimental ABIEncoderV2;\n/gm, ((i) => (m) => (!i++ ? m : ""))(0));
console.log(flattened);
});
An then run npx hardhat flat contracts/ContractToFlatten.sol > Flattened.sol

VM Exception while processing transaction:Gas estimation errored

it is deployed into node by using testrpc it not working in that node especially transferto function and the withdrawal function.how to fix this problem.it's only working in compiler version:0.4.25+commit.59dbf8f1.Emscripten.clang, it's working in higher version of compiler.
The reason why it could be working in higher versions is because you have constructor() function. If you want to have this contract work for previous versions create the constructor function as function ethertransfer() also when you have revert errors most probably it will happen because the conditions you have written in require() statements. Require Statement also accept second parameter a string which you can put description. Check all require statements carefully, another option I would highly suggest is use remix browser ide. There you can debug through the debug tool in that it will help you step in and step over the transaction flow. So that at the end it will be very easy to identify the root cause of the issue.
It seems code is fine,
Make sure that contract has some ethers on balance require(address(this).balance >= amount);
and you calling these functions from owner address require(msg.sender == _owner);
If you use solidity version >= 5.0.0, use withdrawal pattern https://solidity.readthedocs.io/en/v0.5.0/common-patterns.html#withdrawal-pattern