New answers tagged

0

For the docker bit, I believe the COPY and RUN commands being interchanged as Donut mentioned in the comments could help. Reference for this and backing of the claim: Semaphore Article explaining the layer caching. But Since you are using a docker in docker type build this is unlikely to be much. For the Ethereum dev tools themselves, I believe this is as ...


0

Run npm install solc go to package.json check the version of solc after go to truffle.config.json replace he version make sure its the same as in package.json change it on sol ils too


0

Seems the fix for this is similar to this post: https://forum.openzeppelin.com/t/erc20-decimals-specifying-a-big-number/2047/4 Where I needed to use big number libraries multiply and power functions to do the calculation as the number is too big for JavaScript. The test is now working with: const { BN, expectEvent, constants } = require('@openzeppelin/test-...


1

The error was because of a typo mistake. I was passing an undefined argument which caused this error. Its not an error because of no. of arguments.


1

uint256 private constant _Total;// = 1000 * 10**9; If you declare something as constant you must initialise it at the same time. You can't set its value at a later date. (Its value must be known at compile time, so you can't set it during execution.) In your constructor you are not passing in the value that you want to set _Total to, so there's no real need ...


1

When we see, both contracts have fallback function. So, they can receive and send some ether in the platform. As @Rob Hitchens answered the error comes from the balance value of BankA. BankA never can send ether more than its balance. To make your code smarter about this problem, i suggest the followed code that can tell you about BankA's balance: pragma ...


1

The solution to my issue was removing AggV3Int as a required artifact, assigning the address of an already deployed oracle, and changing the deployer function to be async awaiting deployer.deploy.


0

What are the extra 2 parameters 0 and 10 with the testnet link? I think if you change provider: () => new HDWalletProvider(BSC_TESTNET_DEPLOYER_KEY, https://data-seed-prebsc-1-s1.binance.org:8545, 0, 10), to provider: () => new HDWalletProvider(BSC_TESTNET_DEPLOYER_KEY, https://data-seed-prebsc-1-s1.binance.org:8545), It should work.


1

Have a look at this: Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol Notice this little switcheroo: signature = signature.substr(0, 130) + (signature.substr(130) == "00" ? "1b" : "1c"); Hope it helps.


0

For JS > truffle compile Then on the js import ERC20Contract from '../build/contracts/ERC20'; const ERC20Token = new web3.eth.Contract(ERC20Contract.abi, contractAddress)


0

Okay after spending days on this issue I came to know that I was just changing the init_hash once before multiple deployments over testnet. The init_hash changes everytime, so you have to copy the init_hash from pancake pair file into pancake library each time. After doing so I was able to successfully add liquidity using my own router and factory address ...


0

This code doesn't create nor deploy a contract. It takes the address of the deployed instance and casts to the contract type. MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin()); DeployedAddresses is a library created after running the migrations scripts (see details here https://github.com/trufflesuite/truffle/blob/develop/packages/resolver/lib/sources/...


0

When constructing HDWalletProvider pass chainId: 3 can solve the problem. ropsten: { provider: () => new HDWalletProvider({ privateKeys: [testnetPrivateKey], providerOrUrl: `https://eth-ropsten.alchemyapi.io/v2/${ropstenAlchemyApiKey}`, //////////////////////////// chainId: 3 // add this }), I don't know why are this so ...


0

Deep down, you don't interact with the mapping. The public modifier does several things, one of those things is generate a "free" view function. You would get the same effect by removing public and instead, explicitly writing a view function like this: function patient_db(uint index) public view returns(string memory name, string memory blood) { ...


1

Just before those lines I see Bonfire creating a pair on Uniswap. Did you deployed that contract as well on Ganache? is Ganache forking mainnet? IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) ...


1

By https://www.trufflesuite.com/docs/truffle/reference/configuration says, set the compile version in truffle.js module.exports = { compilers: { solc: { version: <string>, // A version or constraint - Ex. "^0.5.0" // Can also be set to "native" to use a native solc } } }


1

your deploy script fails at: await router.addLiquidity(...) while making a call to addLiquidity(), when it reaches: (uint reserveA, uint reserveB) = PancakeLibrary.getReserves(factory, tokenA, tokenB); which in turn fails at: (uint reserve0, uint reserve1,) = IPancakePair(pairFor(factory, tokenA, tokenB)).getReserves(); here the output of pairFor for ...


0

With @truffle/hdwallet-provider you can instantiate it with an array of private keys. const privateKeys = [ "1234..", "8888..", ] const addressIndex = 0 const numberOfAddresses = 2 const providerOrUrl = "http://localhost:8545" ... bscTest: { provider: () => { return new HDWalletProvider({ privateKeys, ...


1

State-changing transactions do not alter the state until the transaction is mined. It's not possible to know the result until the transaction is confirmed because the result may depend on initial conditions and conditions may change between sending and confirmation. Return values are available to other contracts in the case of chain of interactions because ...


1

updated the migration file and then forked a branch from the main net using the following command: ganache-cli --fork https://mainnet.infura.io/v3/YOUR_INFURA_KEY -i 1 This fixed the primary issue of this thread


-2

Would recommend you to get your contracts verified and deployed on the bsc testnet and also add it to tenderly (https://tenderly.co/) and debug the failed tx there you will get the point of failure


1

IERC20(token1).approve(address(sushiRouter), amountIn); IERC20(token2).approve(address(sushiRouter), amountOut); basically when you call approve from inside your contract then inside the approve method the msg.sender is your contract. so replace uint allowed = IERC20(token1).allowance(msg.sender, address(sushiRouter)); with uint allowed = IERC20(token1)....


1

Mapping is a Key-Value storage, such that it stores a record's value as a hash. In fact, when you add a record to mapping by passing your key and value to it, mapping hashes that value. Hash is one-way, that means if one doesn't know hashing key cannot achieve the plain value . The embedded key is used to find the related hash. Finding works the way you give ...


0

I had similar issue when I was learning coding smart contracts. The issue happened for me when I uninstalled truffle and installed it again to get an upgraded version of solidity. The terminal print out for me was as below So I run simply npm audit fix --force I didn't spend time investigating what this command did but I have 0 vulnerabilities now


1

Deploying my contract on rinkeby cost ~12 USD in gas fees Your gas fees are a function of a) the gas required for deploying the contract, and b) the gas price you've chosen. b) can be altered, but with a lower price usually equating to a slower transaction. If it's much lower than the rest of the current market, then it's unlikely the transaction would be ...


0

If you want to see the value of a function that return uint256, try (await [the function that return uint256]()).toString() Uint256 is a kind of number but it is only ready to be displayed as string. On blockchain, every method is asynchronous, remember to add await before each method so that you can pipeline the result


1

You required web3 module but used a method of truffle-contract module while you didn't require it. So, you just can use all methods that web3 provides to you. The command: var theContract=contract_object.new({ from: address, data:contract_byteCode, gas: gasEstimate+10000}) uses truffle-contract module's method. Just replace that with the below command that ...


2

The problem is the array evaluating by info[<index>]. When, one creates a dynamic array, he doesn't determine its length. So, compiler can't understand how many elements that array has and doesn't create any elements for that. However, when one use info[<index>] for accessing or evaluating, compiler sees that element doesn't exist and returns ...


0

In my case, I forgot to specify which contract blockchain-service/migrations folder. Read further the details here: https://www.trufflesuite.com/tutorials/robust-smart-contracts-with-openzeppelin#compiling-and-deploying-the-smart-contract


0

I was able to resolve this by removing - from the script name, deleting node_modules folder and package.json and forcing npm cache clean. Also placed the script in an external folder.


0

Make a .env file in the same folder: MNEMONIC="Your MNEMONICs" INFURA_URL="Your Infura URL with API key" Then replace the truffle-config.js code with this: const HDWallet = require('@truffle/hdwallet-provider'); const dotenv = require('dotenv'); dotenv.config(); const mnemonic = process.env.MNEMONIC; module.exports = { networks: { ...


0

You should be able to use something like a .env file to secure your project secret and keep it from being seen. Alternatively, you could take an approach similar to what this user did for their


2

The more comprehensive explanation can be found here: What are Artifacts In short, truffle artifact is a JSON bundle that contains a lot of useful information related to a contract like the ABI, the contract bytecode, the deployment details, compiler version, etc...


0

try downgrade openzepplin, i think you are trying some very old tutorial. i meet same case. $npm install openzeppelin-solidity@v2.0.0


0

Meanwhile I figured out the issue thanks to this blog post: https://forum.openzeppelin.com/t/truffle-tests-not-being-run-against-contract-deployed-to-ganache-instead-uses-another-contract-address/4402/15 Summary Truffle test always deploys a new contract to ensure tests run on a clean contract (however I couldn't make it visible in Ganache UI) Adding ...


1

const TodoList = artifacts.require("TodoList"); // Enter your Contract Name not File name module.exports = function(deployer) { deployer.deploy(TodoList); };


Top 50 recent answers are included