New answers tagged

0

Execute in console: npm install web3 Make sure that the node_modules folder is in your project directory.


0

The code you provided works just fine for me, too. But the problem is in your Migrations contract. When using Truffle you should leave as it is was created by truffle init command, because it is required for proper Truffle work.


0

First of all, saving a function in a variable in solidity is not possible currently. May be you try to use like JavaScript: var func = function(value){ returns value + 1; } The next thing is, from the comment section, I saw you used uint16 requiredYear = getYear(uint dateStampOfMileStone); You should use if you want to call the function: uint16 ...


0

The code you provided works just fine, assuming you have the right compiler version. To verify, you can just copy+paste the code in Remix https://remix.ethereum.org and change the first line to be pragma solidity ^0.5.1; as that's the default compiler in Remix (I think).


0

A smart contract cannot interact with the outside world because that would break determinism. In case that is hard to parse, for blockchain to work each node needs to be able to verify the whole chain now and in the future. There is no outside source of information that would be guaranteed to reproduce today's input at any point in the future, so it is off-...


0

I am not sure if this will help you. According to what my professor said, oracle can only read the data from the blockchain, you can encrypt the smart contracts which are sending information to oracle. Doing more things on oracle means you will have more privacy than Ethereum. :)


1

Since you are working on Truffle v4, try these commands in an empty folder: npm init -y truffle init You can use truffle init --force as well. Check out this Truffle docs for this. You might want to upgrade Truffle to v5 since v5 allows you to run truffle init in a non-empty folder as well.


1

Assuming that you have the right compiler version (use a different one if needed) you are missing a few keywords from the function: public to denote that the function is accessible everywhere and memory to denote that the string is loaded from memory - string parameters have to be loaded from memory. So the corrected version is: function test() public pure ...


0

I don't think the problem is in the smart contracts. Try looking through the deployment script, imports, etc and make sure you have all the files/data necessary. I'm quite sure that's a JS error.


0

Make sure you have truffle-contract.min.js file in the same location as you are providing in your code i.e., src="./truffle-contract.min.js"


2

There is an alternative method. You can download ganache from the below link $https://github.com/trufflesuite/ganache/releases/download/v1.2.2/ganache-1.2.2-x86_64.AppImage After it has downloaded execute the below command in terminal $cd Downloads $sudo chmod a+x ganache-1.2.2-x86_64.AppImage Now search for ganache and double click on it and press yes ...


1

I guess it is not compatible with node 12.x I managed to install it with node 10.16.0 I also had to install the following to solve some error messages: sudo apt-get install libgconf-2-4 sudo apt install libcanberra-gtk-module libcanberra-gtk3-module


0

for web3 1.2.1(new release) you should use it like: contract_interfact.methods.methodName().call({from:"address"},(err,res) => { ... }) contract_interfact.methods.methodName(arguments).send({from:"address"},(err,res) => { ... })


1

When you want to access Promise object field you could use then such as : If you call var myEntry = Registrar.deployed().entries.call("0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4af") Then you could access real object myEntryObject : var myEntryObject myEntry.then(a => myEntryObject = a) myEntryObject[0]


1

The call is returning the hex value as a big number. 0x186a0 in hex is 100000 in decimal. It is a big number because it is easier to deal with ETH values in that format. To get the number representation from the call, you should do the following: var amount = instance.amount(1) console.log(Number(amount))


2

There is an issue in a way you use HDWalletProvider when configuring development network in truffle-config.js. You should add it like: provider: () => new HDWalletProvider('your mnemonic', 'http://127.0.0.1:7545') For me, it helped. Additional info can be found here.


1

In: let myMemberResult = await this.contract.myMapping(id).myMember; The this.contract.myMapping(id).myMember part is executed before the await part. You can fix it by adding parenthesis: let myMemberResult = (await this.contract.myMapping(id)).myMember; By the way, you could have easily concluded that from the experiment described in your own comment ...


3

I wrote an entire article on this: Writing Accurate Time-Dependent Truffle Tests TL;DR The 1 second comes from run time costs, i.e. the time it takes for the javascript promises to resolve. For increased accuracy, you must use evm_mine with a parameter for the number of seconds you want to jump forwards or backwards in time. Read this PR for more details. ...


0

You must put single quotes around it. '0x0000000000000000000000000000000000000000' worked for me Been hunting down that bug for some time ...


1

token.transfer(accounts[3], amount, { 'from': accounts[2], nonce: await web3.eth.getTransactionCount(accounts[2]) }); add the nonce parameter will fixed the problem, it work for me


0

It is not possible for a contract to "impersonate" somebody else. The solution provided by OpenZeppelin is to setup your contract with the "minter" role. Since your token inherit from ERC721Mintable the owner can call addMinter(contractAddress).


1

As said by @shane you can run the command with the networkId flag or alternatively you can change your config to '*' to match any id provided by ganache.


1

You can set the ganache-cli network ID by using a flag when running it: ganache-cli --networkId 4447


0

this is because evm_mine increase arbitrary times to the latest block and there is no way to fix it because it is how ganache work you can read more at here: https://github.com/trufflesuite/ganache-cli/issues/463 Update: You can't fix the arbitrary times but to get consistency every time you run evm_mine add params in your send method


2

It looks like you deployed to the development network but are running truffle console with the default network, so assume that these are different. You should deploy and use the console on the same network. truffle migrate --network development truffle console --network development As an aside, you shouldn't have to use sudo. You may want to consider ...


1

in your HelloWorld migration file from migrate folder you should open it and by the tutorial add this: var HelloWorld = artifacts.require('HelloWorld'); module.exports = function(deployer) { // Use deployer to state migration tasks. deployer.deploy(HelloWorld); }; you should read the truffle document for more detail: https://www.trufflesuite.com/docs/...


0

Doing this puts the return values in the response array. var repsonse = await basecontract.getInfo("1"); Now you can read the items as array elements like response[0] and response[1]. It worked for me.


-1

//First check the current version $ truffle version //Uninstall previous version when you desire a new version $ sudo npm uninstall -g truffle //install the new version of truffle $ sudo npm install -g truffle //check the version again to know you have got the latest one $ truffle version //try initialize truffle after creating a directory and changing ...


1

Currently, Truffle does not support multiple solc versions. You would have to use a workaround as WyseNinja discovered in this Github issue. What I did was to use 0x's sol-compiler package to compile 1 version (0.4.x) to Truffle artifacts, and another version (0.5.x) natively. sol-compiler allows for usage of multiple solc versions, so I suppose you could ...


0

You are using MintedCrowdsale which requires for the crowdsale to have mint permissions on the token contract. await token.addMinter(crow.address) If you do not want for the crowdsale to mint tokens you have to inherit from AllowanceCrowdsale.


0

I needed a promise-based solution. Copy-pasting from Ethan Wessel's amazing article on truffle time testing: advanceTime = (time) => { return new Promise((resolve, reject) => { web3.currentProvider.send({ jsonrpc: '2.0', method: 'evm_increaseTime', params: [time], id: new Date().getTime() }, (err, result) => { ...


0

On top of Rosco's and Nick's answers, it could also be helpful to know the --show-events flag for debugging. You can use it like this: truffle test --show-events


0

I think your error is not related to drizzle but to git. You need to install git in your machine to have it working. Here's where you can download it for windows https://git-scm.com/download/win once installed check using git --version


1

I was making a mistake in 2_deploy_contracts1.js file. There is module.exports instead of module.export. So the new 2_deploy_contracts1.js file will be; var Election1=artifacts.require("election.sol"); module.exports=function(deployer){ deployer.deploy(Election1) }; Also, I was using the following command to migrate again; truffle migrate Instead, ...


0

For other people's convenience who has similar problem: Look for where the truffle exists: $ whereis truffle if you use zsh, try this: $ where truffle Locate to the directory, and delete it. Re-install with npm


1

It's easy. Assuming you successfully deployed your token contract in a previous file (e.g. 2_migrate_token.js), here's a basic example for 3_deploy_dapp.js: const ERC20 = artifacts.require("./ERC20.sol"); module.exports = async (deployer) => { let erc20Instance = await ERC20.deployed(); // interact with the token contract return deployer.deploy(...


0

Truffle has a debug command that lets you move through your source code. It is not quite easy to use, but still, it is a debug option. See https://www.trufflesuite.com/docs/truffle/getting-started/debugging-your-contracts


0

Your given network_id in networks: was wrong. It should be network_id :"3" if you are connecting with ropsten. network_id :"4" present rinkeby testnet.


1

The truffle-assertion package can easily help with this. Once the package is installed you can run the following: // Import the package to your file const truffleAssert = require('truffle-assertions'); // Deploy the contract let testContract = await TestContract.new() // Get the hash of the deployment transaction let txHash = testContract.transactionHash ...


1

In your case you have 2 running blockchains. The first one is developement blockchain spawned by truffle and you can access its rpc using : http://127.0.0.1:9545 as shown in your terminal and the second one is ganache's chain which you can access its RPC using http://127.0.0.1:7545 If you are deploying your contract using Truffle look at truffle.js file ...


0

It seems truffle has lost control over his project, and there are too many conflict between version to version of truffle, used compiler, network type, script adjustment and many conflict, even in latest version, it throws error simply while compiling or deploying, I was forced to degrade version, but with 5.0.10 also there are too many conflict. So in a ...


0

Dear Friend actually truffle developer team has lost control over his project, patching one side creating problem on other side. ( even on their official forum 80% questions are not addressed and in most cases question is for X and reply is for Y ) Now I think they have only one way to start new project with similar goal with fresh and restructured ...


0

Actually many similar questions of mine not answered yet (even at official forum of truffle 80% questions not addressed ), which clearly indicates that either truffle developers have lost control over project means patching one side creating problem on other side, or they leave this project as Orphan, so don't expect any logical clear answer for your ...


Top 50 recent answers are included