New answers tagged

0

drizzle is a redux store that exports objects like drizzle and drizzleState to any component that uses DrizzleContex or that get's the objects via props. The trick of drizzle is that it organizes the communication with the blockchain and syncs it to its redux store. So you only need to communicate with the store throug cacheCall, cacheSend and so on. So ...


0

If you have the drizzle object available, you just find it at drizzle.web3 If you use drizzle context or drizzle-react. drizzle is just an object that you can access directly. Make sure drizzle is in sync and not undefined. For example if(drizzle !== undefinde) console.log(drizzle.web3) and there it is.


0

The address is part of the contract API that is loaded together with the drizzle option So when you just console.log(drizzle) there is the solution. You can view the address directly in you Chrom-Browser when openening the dev tools -> console Let's assume your contact name is SimpleToken, then drizzle.contracts.SimpleToken.address hold the contract ...


2

Actually never mind, I just found the solution, which is definitely not very intuitive. I leave it here in case it can help someone. const level = web3.utils.toBN(1); // <------ we must use this function truffleAssert.eventEmitted(tx, 'EventName', {level}); // now this works So just using web3.utils.toBN suffices.


0

ContractData returns a jsx-element and not a BigNumber. Just look in the code of ContractData. So requesting the value of the BigNumber which is a string, not a jsx-Element. So the only way I think is feasable is to hack ContractData an pass it a handler that reads out the BigNumber. For this you need to break the api and add a new prop to it. The other ...


0

Regarding // this does not work const dataKey2 = contract.methods.setNumber.cacheSend(3); console.log(dataKey2); So, sending is a little bit different, because send will be passed through the cache to blockchain. So cacheCall will do it directly. The drizzle api is like web3 and therefore you also need to pass an object from whom you like to send it. I ...


0

I'm sure an answer is no longer needed for this, but in case anyone else has the same problem, --networks should be --network.


0

I prefer this syntax: module.exports = function(deployer, network, accounts) { deployer.then(async () => { await deployer.deploy(A); await deployer.deploy(B, A.address); //... }); }; since it's way more readable when you have lots of contracts. See also: https://github.com/trufflesuite/truffle/issues/501#issuecomment-...


1

I prefer this syntax: module.exports = function(deployer, network, accounts) { deployer.then(async () => { await deployer.deploy(A); await deployer.deploy(B, A.address); //... }); }; since it's way more readable when you have lots of contracts. See also: https://github.com/trufflesuite/truffle/issues/501#issuecomment-...


1

If you are behind organizational proxy, clone the git repo. In the case of truffle pet-shop git clone https://github.com/truffle-box/pet-shop-box.git cd pet-shop-box rm -rf .git # Remove the .git record npm install


0

I already install git in my computer. However, I forget to set it to environment variables. After I set it, the error disappeared and unboxed react successfully. The solution of this error is to set git to environment variables.


0

When deploying a contract you eventually need to sign a transaction with an account (with a private key). This account management process is handled by the provider, in this case, the @truffle/hdwallet-provider (Note that truffle-hdwallet-provider is deprecated). This could be another provider like Metamask or a local Web3 provider.


0

Try to regenerate the JSON file by deleting the old JSON file and re-compiling .sol file. It worked for me.


1

Since this part doesn't return anything: .then(hash => { assert.equal(hash.valueOf(), hash_test, "Not returning the correct address"); console.log("THIS"); }) No other then is executed passed this point, and the it completes successfully. I'm assuming that you have two additional its in your test, hence the printout 3 passing. Aside from that, ...


0

I think I figured it out (please feel free to chime in) I followed instructions to install nodejs via nvm here, https://www.ostechnix.com/install-node-js-linux/ Then I executed npm install -g truffle Now when I run truffle version, I get Truffle v5.1.2 (core: 5.1.2) Solidity v0.5.12 (solc-js) Node v13.2.0 Web3.js v1.2.2


0

Reply to @jazzhole answer. the repo got updated , here is the updated link


0

The answer is: I need to reset metamask between sessions: Settings > advanced > Reset Account Not sure why this is needed for ganache gui but not ganache cli!


1

Smart contracts are generally available to all users of the blockchain. Testnets like Ropsten and Kovan are public test blockchains which are available for everyone and therefore also all smart contracts in them are available for everyone. One of the main points of blockchains is that multiple users can access them at the same time. So, yes, multiple users ...


1

selfdestruct requires a parameter of type address payable. What is the type of owner in your code.? If you're using the OpenZeppelin Ownable.sol, it's not payable. You could cast it, but since you've already required that _owner is equal to owner, and the former is payable you should simply be able to write selfdestruct(_owner); instead.


1

You have two different issues here: First, the syntax addExam().call(...) is incorrect. It should be either addExam.call(...) or addExam(...). Second, the usage of call by itself is incorrect. Since function addExam changes the state of your contract, you should use sendTransaction. In short, change this: instance.addExam().call(hash_test, {from: ...


1

Change line 4 to: address payable admin; Hope it helps.


0

You are trying to connect to http://localhost:9545 while your node listens on port: 8545. Thus Web3 API connection was refused.


0

I will assume you are using windows because I got the same problem: first I search for the error "npm ERR! code EISGIT". Solution I found is by using this command rm -rf node_modules/*/.git/ Next, I encountered with another errors related to python. I didn't have python in windows, so I installed python 2.7 and drizzle installed correctly... I'm following ...


0

To do this in pure chai, you can use these two approaches: const expected = web3.utils.toBN('123.052'); const actual = await meta.getBalance.call(account_two); expect(actual).to.eql(expected); // compare to BigNumber or use strings: const actual = (await meta.getBalance.call(account_two)).toString(); expect(actual).to.equal('123.052'); Note that you have ...


1

Your issue here is that your call is not passing hash as a parameter, but rather as an option to Truffle. In reference to this line: let hash = instance.addExam.call({from: accounts[0], hash: hash_test}); The options provided inside curly brackets do not go on to the function call, but are passed to Truffle. Also, Solidity doesn't support named arguments, ...


2

You are doing the invocation wrong, try with the following: it("should keep the contract owner", async () => { let instance = await Example.deployed(); let address = await instance.getContractOwner.call({from: accounts[0]}); // console.log(address); assert.equal(address.valueOf(), "0x67F4CfB03aA5E2E71De1470ae26adB7e33B7892E", "the address is ...


0

The problem was in truffle-config.js . I had commented some relevant lines. Truffle should throw something in this case.


0

If you tried all above solutions and still its not working then try to add Path "C:\Users\xxx\AppData\Roaming\npm" in environment variables.


0

In summary, the factory makes the deployed contract addresses discoverable. This is by emitting an event with created address and/or storing them in an array with functions to explore the state - preferably both. The app then uses the ABI for the deployed contract(s) at the addresses where the factory informs it something exists. Hope it helps.


0

When working with Truffle v5.0.39, the above-mentioned syntax is not valid. If the contract's constructor has arguments, the deploy function has to provide the arguments like this: deployer.deploy( myContract, arg1, arg2, ...); So, for example, if your constructor takes two addresses: deployer.deploy(towater, "0x15458ef540ade6068dfe2f44e8fa733c", "...


Top 50 recent answers are included