New answers tagged

0

It is possible to do something like this: struct Location { string city; string street; uint time; } struct Product { uint id; string name; mapping (uint => Location) locations; } mapping (uint => Product) products; Then the implementations will be like: function viewLocation(uint _productID, uint _location) public returns(...


0

The method you described would work. A cost optimization would be to log an event whenever a user sent their tokens to the contract. This would remove the requirement for both an array and a mapping. When attempting to read the data off-chain (for the swap to the other token), you can simply read each event that occurred on that contract. An example would be:...


0

In solidity the hash is generated using: function generateHash(param1, param2, ... paramN) public pure returns (bytes32) { return keccak256(abi.encodePacked(param1, param2, ... paramN)); } In web3.js v1.2.6, the same hash can be generated using: web3.utils.soliditySha3(param1, param2, ... paramN); Example: > const web3 = require('web3'); > ...


0

Two obvious approaches spring to mind. PUSH An off-chain process would listen to Token A's event log to compile a list of holders and then proactively send Token B. Since Token A is constantly in motion, either a cut-off time or a continuous process and the requirement should be clarified. A notable disadvantage of this approach is the centralized gas ...


1

I tried the deployed contracts and they work as expected. KombuchaProxy shouldn't update Kombucha contract. It updates its own storage. The whole idea of a proxy is that it contains the data and point to another contract that has the code. To test this in Remix I instantiated Kombucha contract at KombuchaProxy address. Now you can execute Kombucha ...


0

It's actually part of a broader concern. You can put access control on a read-only function, but an adversary will: Have all of your code Have all of the data Therefore, an adversary will get around any notion of confidentiality you construct. private doesn't change that. The most you can do is inconvenience a determined adversary. Since it is ...


1

The more realistic situation will be to send from 100 different addresses. From an ethereum client perspective there is some difference but not much. For a miner it should not matter. Once the proposed block is created by the client the proof of work algorithm execution will be the same.


1

function Mycontract() payable{} is the contract constructor. It is only executed when the contract is deployed. Marking it as payable means you can attach a certain amount when you create the contract. If you want to to allow anyone to send Ether to your contract, you need to make your contract's fallback method payable. You define it like this: contract ...


0

Let me try to put this in a simpler way: When MultiSigWallet is deployed it takes an array of owners and the number of confirmations required for executing a transaction. function MultiSigWallet(address[] _owners, uint _required){ //Logic } The purpose of multisig wallets is to increase security by requiring multiple parties to agree on transactions ...


0

There are non-obvious design considerations. It is not trivial. Option 1 - Trustful Process You have already re-introduced centralization into your token by giving the owner the extraordinary privilege of minting new tokens for itself without restriction. If that is a concern, i.e. likely unacceptable to holders, then you need to eliminate that privilege. ...


0

I figured it out :) You keep a running total of the average timestamp that each user deposits- only needs to be updated when each new user joins. You then take the difference between this average and the current timestamp, and multiply by number of users. This gives you the total time held by all users, without looping.


0

One problem with encrypting data and putting it on chain is that you're leaving your encrypted data on a public immutable data store forever. What if some radical new computing paradigm (quantum?) can break the encryption, or your keys are stolen? This problem is one that the Baseline Protocol is aiming to solve, see: https://docs.baseline-protocol.org In ...


Top 50 recent answers are included