Hot answers tagged

5

All variables on Ethereum are accessible and readable by everyone in the contract storage, even if they are marked private. In the situation where you want to access the contract storage, you can do so using web3.eth.getStorageAt(): web3.eth.getStorageAt(contractAddress, 0) .then(console.log); If your contract only stores this one variable, it should be ...


3

Your public and internal fields can still be modified by your child contract. I can think of situations when this may be a problem: if a data change needs to be followed by some action, like an event. if the data should not be modified by mistake by a child contract. If you are in this situation, you should make the field private and create a getter and a ...


2

This doesn't appear to be your correct address. I checked on etherscan and it shows no transactions in this address at all. A valid presale address should show the initial balance plus any subsequent transactions. Your presale wallet should be a json file, secured by a passphrase. You can import that into an Ethereum wallet such as MyEtherWallet or Parity. ...


2

Here is how you can do this with a bit of bit trickery (at the cost of 450 gas): function setByte(bytes16 x, uint8 i, byte b) returns (bytes16) { bytes16 mask = bytes16(0xff) << i*8; return (x & ~mask) | (bytes16(b) >> (15-i)*8); }


2

For simple value types like uint and bytes32, use the public modifier. This is less verbose and often more efficient. If you need to access more complicated types like structs and arrays, it often makes sense to create your own getter to return the data in a format that makes sense for your use case. Essentially, use the public modifier when you can, but ...


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


1

I think this behavior is due to the fact that you're passing struct between contract. As you might know they should be passed internally. That said you need to use getNameMain Here you'll find a similar discussion copy a struct from Contract A into a struct in Contract B using Contract C


1

I think its doable. Yes, users would be permitted or denied access to a function based on their address. Its worth noting that such restriction would not apply to read-only operations owing to the transparent nature of ethereum. A good starting point is role-based access control in the open zeppelin library. https://openzeppelin.org/api/docs/...


1

This cannot be done, as Ethereum is an open, public network. There are things to be done that will prevent other contracts interacting with it, such as making functions internally callable, but in doing so you will remove the ability for your Dapp to interact with it. What it sounds like you are looking for is either a traditional database or a private ...


1

It is very much possible to see values of even private variables stored in the smart contract. Refer the following blog for more details - https://hackernoon.com/your-private-solidity-variable-is-not-private-save-it-before-it-becomes-public-52a723f29f5e


1

This is not specifically an Ethereum question, more like something related to Linux. You essentially want to block all other IPs other than your designated one to access your server at port 8545. Terminal one liner, shamelessly taken from this thread: iptables -I INPUT \! --src 1.2.3.4 -m tcp -p tcp --dport 8545 -j DROP It will drop access to all IPs on ...


1

It depends how you write the contract. You get the access control you design. There are more intricate access control patterns such as whitelists, but to lay out a simple example that is admittedly flawed, but hopefully illustrative: contract Greeter { address public owner; function Greeter() public { owner = msg.sender; // <= the "owner" ...


1

Well, based on the signature of your mint() function, people will be able to call it directly, interacting with the token contract directly. Usually, projects who do ICOs tend to do the token and crowdsale in one contract. If you don't want to do that, you can make it so only your crowdsale contract can call the function by restricting its access. contract ...


1

Make sure you put quotes around the address when specifying it as a constructor parameter. Remix does a very poor job of parsing unquoted hexadecimal strings. I could reproduce the behavior you saw only by using an unquoted hexadecimal string. With quotes, it worked correctly all 10 times I attempted it.


1

Search Google for the words "DAPP," "Distributed Application," "Solidity," "Web3.0," "Truffle," "RPC," "EVM," "MyEtherWallet," "Metamask," "Infura," and read, read, read. These are sort of the basics. If you have a moderately good understanding of each of these things, you'll be on your way. I ordered the words in the way you might come to understand the ...


Only top voted, non community-wiki answers of a minimum length are eligible