New answers tagged

1

The address you provided is 95 characters long. That means 190 bytes. That will not fit in any byte arrays Solidity supports. Your only options for storing it are either a string or bytes (dynamically-sized arrays, see https://solidity.readthedocs.io/en/v0.5.3/types.html#arrays for more details). But there are no efficiency improvements between those two ...


3

OpenZeppelin uses the "unstructured storage" proxy pattern. See the documentation for details: https://docs.openzeppelin.com/sdk/2.5/pattern OpenZeppelin in the proxy patterns blog post (https://blog.openzeppelin.com/proxy-patterns/) explored three proxy pattern options: Inherited Storage Eternal Storage Unstructured Storage An upgradeable contract ...


1

These 4 are really very well-know patters. (1) After analysing Delegatecall-based approach, I give up it because of two main reasons: you can only add new variables not delete or change existing ones. So, if you have a struct defined and you want to change a type or add an existing field, if you want to delete a variable etc.... you cannot. Also, it makes ...


0

You can provide your token smart contract-extensibility by 'wrapping your token' by something that can interact with the contracts, i.e., ERC-20 tokens. Here is a detailed article on how to go about it. The sample Weth interface provided: contract IWETH is ERC20 { event Deposit(address indexed sender, uint256 amount); event Withdrawal(address indexed ...


0

one account (account A) can be seen as an owner of a token so that they can use them in other services(e.g. using its right to receive dividends) This you can implement with the existing interface as is and perhaps with a new function to calculate dividend. other accounts (lets say secondary owners) can prevent A to transfer token to others on Dex or any ...


0

First all, why would you want to? It is seldom necessary to do something like that. A good rule of thumb is to treat sorting as a method of last resort. In databases, sorted lists help efficiently locate keys of interest O(log n). In Ethereum contracts, mapping accomplishes the same in O(1). The most common reasons for sorting data are poor justifications ...


0

You need to use doubly linked list like this: struct GameListItem { uint prev; uint next; } mapping (uint => GameListItem) public openGamesList; uint public firstOpenGame; function addOpenGame (uint gameID) internal { require (gameID != 0, "Game ID is NULL"); GameListItem storage item = openGamesList [gameID]; require (item.next == 0, "...


0

Basically any way of generating randomness within a contract is prone to abuse and is unsafe. Deterministic contracts are really bad at generating random numbers. In your case it is easy to check what is the latest latestSeed and then calculate the right stake to trigger winning to make yourself win (or if not possible currently then wait for the next ...


1

I can use the following function: function foo(uint n) public { require(yourContract.winningThreshold() == yourContract.registrarCounter() + 1); uint CurrentStake = yourContract.stake(); yourContract.register(n); uint[] memory seeds = yourContract.revealWinningSeeds(); require(seeds[seeds.length - 1] > currentStake); } Every non-...


2

All smart contracts have an address that can be used to identify the contract. For example, the address for this contract is 0xE1Ac9Eb7cDDAbfd9e5CA49c23bd521aFcDF8BE49.


0

Just a update to this question, but this time it use a technique call verifiable delay function (vdf). It was built based upon time lock puzzle invented by Ronald L Rivest et al. The core idea behind is that if you can't calculate the result in a set amount of time, then the result is pseudo random. So with that in mind, vdf is a function which take in an ...


1

Return an array of struct from a function pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; contract Money { struct People{ uint id; string name; uint amount; } mapping (uint => People) public peoples; event votedEvent(uint indexed _candidateId); uint public candidateConut; constructor() public { candidateConut = 0; ...


-1

The following code works as you need: pragma solidity 0.5.0; contract UserManager { struct User { string username; string password; address userid; bool isAdmin; } mapping (uint => User) users; uint totalUsers=0; function checkIfUserExists(address userid) public view returns(bool) { for (uint o = 0; o < ...


1

The problem is not with your code. The problem is the order of issuing transactions. You should follow the following steps: Deploy MainContract Issue createNewContract and get the returned address of the deployed SubToken Contract. ** Note that this address is the address of SubToken contract which has been deployed in createNewContract method. You need ...


Top 50 recent answers are included