New answers tagged

0

Part answer... The issue is in the refund() function. This line requires the use of range() (nextContributorsIndex is an integer, not an array): for i in self.nextContributorsIndex: Should be: for i in range(self.nextContributorsIndex): Having said this, PR #1100 introduced the requirement that the input to range() should be a constant, and your ...


0

So many basic errors: When stating the return-value type in the function declaration, you should be using returns, not return There is no such type unit; you probably meant uint You forgot to declare 2 out of 3 functions as view; while this will compile successfully, it will make your life harder when you call these functions from the off-chain You named ...


0

While you can try a web automation tool, this will be slow and often brittle. A better approach would be use npm and a small script which loads web3js and the text file. Then you can parse the text file and submit the transactions via methods of web3js The code under "Usage" should get you started: https://github.com/ethereum/web3.js/


0

I had a quick look - the INVALID instruction is 0x1C which is SHR or bitwise shift right. This was added in the Constantinople hard fork in February of this year (EIP145). My guess is that the Remix debugger hasn't been updated to include this instruction.


3

Two options: Change memory to storage, otherwise you're just creating a local Document object rather than referencing your documents mapping. Declare Document memory document at the beginning of the function, then initialize the fields of this object (as you are already doing), and finally set documents[_hash] = document at the end of the function.


1

Function createTokens is declared external, but you are calling it inside the contract. In order to be able to call it from both inside and outside the contract, declare it public.


1

I wasn't sure which compiler you were using so I choose one at the high end of 0.4.x that supports constructor. You need to add public visibility to your id and name in anotherContract so they are visible. Contract names should be written out in CamelCase. pragma solidity 0.4.26; // be specific contract MyContract { address[] public childContracts; ...


0

When working with web3.js version 1.2.x, there is not .getData method. The solution I found was to estimate of gas of the .deploy() method, which effectively returns the cost of contract creation. The sequence of operations is: let contractJSON = // JSON compiled contract const contractABI = contractJSON.abi; const bytecode = contractJSON.bytecode; const ...


1

abi.encode(bytes4(keccak256('balanceOf(address)')), (sender)) Should be: abi.encodeWithSelector(bytes4(keccak256(bytes("balanceOf(address)"))), sender) or, which is the same abi.encodeWithSignature("balanceOf(address)", sender) Function abi.encode pads all arguments, including the first one, to 32-bytes. In your case 4-bytes function selector was ...


0

I believe that you should change this: abi.encode(bytes4(keccak256("balanceOf(address)")) To this: abi.encodeWithSelector(bytes4(uint256(keccak256("balanceOf(address)") >> (256 - 4 * 8))) The shift-right operation is in order to extract the (32-bit) function selector out of the (256-bit) hash generated by the keccak256 built-in function. You can ...


0

In initial state (after deploying) contributions.length = 0. Executing contributionID = contributions.length++; returns the value 0 (set contributionID to 0) and afterwards increases the lenght of the array by 1. That is why the first contribution ID will be 0.


1

Try this declaration for person: Person memory govt = Person(owner, 'Owner', 'Owner', 0, 'None', new uint[](0), new uint[](0)); I'd recommend reading a little more about arrays in Solidity. You'll need to decide if you want your arrays to be memory or storage, which is very dependent on what your goals are. Since you've assigned them to size zero, please ...


0

You can't create oraclize-linked contract using "Javascript VM". Just because there is no oraclize contract there. Try to deploy the contract to the one of public testnets, for example, in Ropsten.


0

Do: function _callback(bytes32 queryid, ....) payable { ... } You just need to append the word payable to the function.


2

I input the string "Cow", to a function in the smart contract. Next, I should be able to create a parent token which represents the string, and each child token should have a numerical ID within the range 1-50. A contract factory could serve as both an ERC721 deployer and a registry (inventory) of the deployed tokens. ERC721, itself takes care of ...


0

If you face any issue while connecting with the network(let say ganache) you can try the following steps: make sure ganache is up and running(ideally on port 8545) from remix change the environment to Web3 Provider and confirm the address from the popup window. in case you want to connect through the metamask, change remix environment to Injected web3. Make ...


0

I managed to find out what the issue with the compile, I always been deploying to the wrong contract: It seems like the list highlighted is in alphabetical order, therefore unknowing I always have been trying to deploy the abstract/interface contract which prompt the error. All I need to do is to go to the drop down and select my contract and it would work....


2

(I'm sure this has come up before. If someone can find a previous answer then please duplicate... ) From the Yellow Paper, Appendix G, you'll see the following line: Gsset - 20000 - Paid for an SSTORE operation when the storage value is set to non-zero from zero. Meaning the first time you write a variable to storage, it's more expensive by 20,000 gas....


1

This is not unique to arrays, but to any state-variable in your contract. Changing from zero to non-zero costs more gas than changing from non-zero to non-zero.


0

OK, first of all you need to convert all amounts to basic units. For ether, basic unit is Wei and 1 ETH = 1e18 Wei (1,000,000,000,000,000,000 Wei). So, 1 ETH = 1e18 Wei (1,000,000,000,000,000,000 Wei) 0.1 ETH = 1e17 Wei (100,000,000,000,000,000 Wei) 0.01 ETH = 1e16 Wei (10,000,000,000,000,000 Wei) 0.001 ETH = 1e15 Wei (1,000,000,000,000,000 Wei) You ...


0

I did not completely understand your requirement or issue you are facing, but I copied the contract you shared to remix. I am able to reproduce the error you have mentioned... This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly. This is when you try to deploy ...


0

The short answer is you would make your own access control. RBAC is a specific approach. A suggestion would be to use the even simpler Ownable.sol (OpenZeppelin) example as a template, for ideas. The basic idea is to define your guards. modifier afterMidnight { // require(something, "patience. party hasn't started"); _; } function living() public ...


0

I have tested your code in remix and its working fine for me in both cases, either using JavaScript VM or Injected Web3. I would suggest the following steps to try: First, in Remix select the compiler version 0.5.11+commit.c082d0b4 and try to deploy it with JavaScript VM. if this is successful then move to the next step. Change the Remix environment to ...


0

It seems that your contract are failed to compile with pragma solidity ^0.5.11 and thus you are trying to deploy empty byte code. That's why you get this "message" must be a nonempty string warning, and that's why deployment fails. Probably the tool you are using for deployment runs Solidity 0.4.x.


0

I don't know what you are using for your deployment like 'Javascript VM' or 'injected web3', but maybe using 'injected web3' will solve your problem or if you are already using that, then go to metamask and try to reset your account. This helped me get rid of this error but I am not sure if this is the right solution for you. Note: New here! Any ...


Top 50 recent answers are included