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

It looks like in order to avoid the Stack too deep, although function argument can take 16 parameters, the safest way is to avoid exceeding the 16 parameter number else you run into a Stack too deep error.


2

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 ...


1

In most cases, I would avoid require in a check like that to make it safe to check. if(duration < min) return false; if(duration > max) return false; return true; A caller that is considering a state change can require(contract.durationIsValid()); That is easily incorporated into a modifier if that is wanted, and the intricacies of the logic would ...


0

So you have a smart contract with a function which accepts a string parameter. When you send a transaction to that contract targeting that function with some string parameter the transaction will eventually get mined and included in a block. You can't control to which block it gets added. So, if you send a transaction with a string to a smart contract (...


1

Your code doesn't make much sense. The function either returns true or throws an exception, so what exactly is the point in returning a single possible value? One could simply conclude that if the function hasn't thrown an exception then the answer is true. With regards to the actual question about using require: Revert (embedded in require) is useful ...


3

This is possible, but not advised. If you do this, you should cast the int32 to an int256 in order to be explicit. int32 a = 1; int256 b = 3; int256 c = int256(a) + b; However, using types smaller than 32 bytes may actually be more expensive than using types that are 32 bytes exactly (such as int256, uint256, etc.). The reason for this is that the EVM ...


1

You can simplify your setup to only 2 contracts. I've taken the liberty of editing the contracts a bit to make the testing a lot easier and more specific. You can copy paste them in Remix and test yourself. contract A { B b; constructor(B _b) public { b = _b; } function() external payable { (bool success, bytes memory ...


0

If you want to get financial data, and don't want to wait a block (or more) and pay GAS and then ETH fees with something like Oraclize, you can get stock, crypto, ETF, etc data from the OrFeed.org's smart contract for free and instantly from your smart contract. For realtime prices from Dexes like Kyber and Uniswap: uint price = orfeed.getExchangeRate("ETH"...


0

You can get stock, crypto, ETF, etc data from the OrFeed.org smart contract: examples: Forex: uint price = orfeed.getExchangeRate("JPY", "USD", "DEFAULT", 100000); Stock: uint price = orfeed.getExchangeRate("AAPL", "USD", "PROVIDER1", 1); or realtime from a DEX: uint price = orfeed.getExchangeRate("BTC", "DAI", "SELL-UNISWAP-EXCHANGE", 100);


0

The idea is to separate your functionality in two functions. Here foo will fail and revert and bar which will delegatecall to foo in the same contract. contract A { uint256 public counter = 1; event DelegateCallFailed(); function foo() public { counter += 1000; // Make to always revert revert(); } function bar()...


2

No language on Ethereum is Turing complete, because the EVM isn't Turing complete. There is a maximum gas limit, which means no operation can run for unlimited time or use unlimited space. Vyper just makes that more clear than Solidity does.


0

The question is not clear and your intent is not easily surmised from the code. I suggest rephrasing and focusing on one thing at a time. The first thing that jumps out is the effect of throw, now called revert in more current compilers. It will reverse everything that preceded the statement so it will always appear that nothing happened except gas ...


2

The value of msg.value is always the amount of Ethers sent with the (internal) transaction - if contract A calls contract B it may pass along less Ethers than msg.value and then msg.value in B is the new amount. So, yes, the whole amount will be taken from msg.sender (or, more specifically, from tx.origin - the EOA who initially started the transaction). ...


0

To begin with, change this: deploy(Ticket, 0) To this: deploy(Ticket, "0x0000000000000000000000000000000000000000") Since 0 is not a valid address value when sent from web3.js.


1

You can check the length of the bytes of the value. You do this by converting the string to bytes and checking the length. If it is greater than 0, than it exists. Your new code would be as follows: if(bytes(professorsExamHash).length == 0){ return "No exam hash asociated with this professor address"; }


1

Everybody can execute run(), nobody can set started directly. Since started is public, a getter (but no setter) is automatically generated. Reinitialization of the smart contract is not possible, unless you define a specific function for this task.


0

every contract should have a private key somewhere The private key exists in theory, but since the contract address is not generated by choosing a private key to begin with, the private key of that address remains unknown (and unlikely to be discovered under the current computation limits). it should be possible to send ether to it Only if it implements ...


0

You can't do it. It is not possible to write a contract that directly accesses the wallet of another user or the storage of another contract. So, you need a different approach. Consider users that give the contract authorization to manage a certain amount of money. That can include redistributing to other users according to the rules. Think about an ...


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

Unfortunately Mist has been deprecated. I recommend using Remix for deploying smart contracts, and MetaMask for interacting with DApps.


0

The question is not clear enough, but if I understood you right. You need to perform an action when all goldNodes replied and until then you wait. I am sharing a sample code, where allGoldNodesReplied is false and it's said to true when all nodes reply. For that, your contract must know all goldNodes and their count and maybe some more info to prevent one ...


0

So I am betting on the fact that at least one of these 2 lines will revert The only line in your code which may revert is msg.sender.transfer(_available). This line will revert if address(this).balance < _available. If msg.sender is a contract, then it may revert also when address(this).balance >= _available. Other than that, the line balances[msg....


0

Your code looks fine to me. If you take a look at the SafeMath library's subtraction function, you can see that it works in a similar manner: function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } What you're doing ...


0

Some tokens use a special value in allowance to minimize gas fees when used in combination with approve/transferFrom. If allowance is that special value it will skip updating it, saving one storage modification. If you perform multiple transactions for example in decentralized exchanges you will have important savings over time. It is a "hackish" way to ...


0

There is a recommendation from Oyente that Allow _ at the beginning of the mixed_case match for private variables and unused parameters. And says: mixedCase (differs from CapitalizedWords by initial lowercase character!)


0

Tools exist to convert the ABI into a Solidity interface, which contains all of the function names. In Python - abi2solc In Javascript - abi2solidity The data in an ABI is generic enough that interfaces can be generated to work with ^0.5.0 or ^0.4.22, or earlier if tuple types aren't used.


3

The pattern you are using is valid for certain table-like sets, but you should be aware of the limitations. It is ill-advised to do anything with a contract that loops - Getting Loopy with Solidity. You can, however, make it possible for a client to loop. It should be understood that "client" is an off-chain entity, in this context, because if it wasn't ...


4

Trust me. Everytime (everytime!) you are thinking to loop trough a dataset whose dimensions you cannot predict at the “start of the time“ in a blockchain based system, you are using blockchain for the wrong thing and/or your algorithm must be changed by rethinking it. Your model should be something where if a new “user” is added, the simply operation to add ...


1

You're missing () after myContractInstance.methods['0xc4e41b22'].


0

You just have to trust the contract. The idea is that contract's code is public (byte code, I mean), so everybody may analyse it and decide, whether to trust it. The reality is that byte code is unreadable, so people anslyse source code instead, and then ensure, that compiling that source code produce exactly the same byte code as published on chain (here ...


0

Thanks for that quick response. I would like to clear my question. Suppose for this transaction: https://etherscan.io/tx/0x89221691a67b15427c97f1fd0cd65966ff617728cd897be27d88a04ee0bc1e2d Ether is being transferred via Contract. All I get to know from the contract's event list is that the event Transacted was emitted. I want to be sure about the authenticity ...


0

I'm a bit unsure whether you really mean Ether transfers or (ERC20) token transfers. Ether transfers don't emit any events (unless some contract happens to emit upon receiving Ethers). If you transfer Ether between EOA (Externally Owned Account) without contracts there will certainly be no events emitted. So let me provide an answer for both cases, just in ...


0

Just create a function like this: address payable public owner; modifier onlyOwner { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function kill() public onlyOwner { selfdestruct(owner); } The kill function uses the selfdestruct function to "destroy" the contract making it unusable and effectively killing it....


0

In short This is not a reentrance attack. The actual vulnerability is the contract's mechanism allows cheap trail-and-error, until there a "hit". (Interestingly, "hit" is also the name of attacker's contract method) Attack Mechanism The attacker deployed a contract that calls random to see if a Win will happen. If yes, loop and call send 100 times. If ...


2

I haven't studied this in-depth but I see a clear problem outside of the mutex. This is not random. function random() private view returns(uint){ uint source = block.difficulty + now; bytes memory source_b = toBytes(source); return uint(keccak256(source_b)) % 100; } It is also not hard to guess. You are trying to make ...


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

What you are doing wrong is in your code myContAddr is string and you are trying access parameters of this variable. To access .methods.getTotalSupply().call() you need to create contract instance using the following code: async function myContractAddress() { var myContAddr = '0x552F3AfaA0394632f4aEfa9E923fA3e2bbDAF5FE'; var myContractAbiDefenition =...


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....


Top 50 recent answers are included