New answers tagged

0

Yes. You create a bool. address public isPaused; You create a modifier modifier onlyIfRunning { require(!isPaused); _; } You decide which functions should freeze in the paused state (not necessarily everything). You add the modifier. function deposit() public payable onlyIfRunning ... You create a function to set the flag: function ...


0

I solved the problem , contract need ether to work function2(in my case) , so ...this is the "Invaild opcode" solution.


1

No there is not any database/method to do that. You have to must implement a python script between your deployed smartcontract and SQL database.


1

Yes, you do need to change function Contract (... to constructor(... because this is the new way to indicate the constructor. There is nothing else you need to do in the Factory to invoke the constructor. The constructor always runs one time on deployment, regardless of how the contract is deployed. It cannot be prevented/avoided even if you want to. In ...


0

Take a look at implementing OpenZeppelins ERC20Mintable contract. They create re-usable standards that make it easy to implement generic functionality across your smart contract system. See here for the current implementation.


0

Here are some ideas to start. Your transfer() requires the destination is not address(0). Great, because tokens sent there would be burnt. You can make a burn() function that lets a sender destroy some tokens. No need for address to. It will be address(0). Since the tokens would not be recoverable, you could also adjust the total supply. Subtract the ...


-1

Check this out: Sign the transaction using backend server without metamask I think it is better to solve the problem using a back-end server, which means back-end server is the one responsible for all the blockchain transactions confirmation. The link shows how to make transaction without pop-up window from metamask - using provider from Infura.


1

I'm a little unsure of what you want, but assuming _id is unrelated to an item's position in the list and you require a way to enumerate the Users in the system, you probably need both an array and a mapping, i.e.: import "./User.sol"; contract Main is Ownable { User[] private _users; mapping(uint256 => bool) userExists; function ...


0

Use a mapping instead of an array: mapping (uint256 => User) private users; uint256 private numOfUsers; function createUser(uint256 _id) onlyOwner external { require(users[_id] == User(0), "User already exists"); users[_id] = new User(_id); emit UserCreated(users[_id], ++numOfUsers); }


1

This is a very broad question and I almost voted to close this as 'too broad'. The answer also depends quite much on what other assumptions we make about the business case. So something like the following might be required as well: 1) Do you want to implement your business case with a blockchain at all? If yes, is Ethereum the right choice? Private or ...


1

Assuming order doesn't matter (implied by "set"), the combination of a mapping and an array can handle set operations in constant time. The trick is to keep track of where in the array each element is and swap elements to the end for deletion. I wrote a blog post about this pattern: https://programtheblockchain.com/posts/2018/06/03/storage-patterns-set/. ...


0

In your case, just have a simple test contract to send a small amount of ether or tokens sent from the transfer function of the original contract. Then check the balance of where it was supposed to be sent, still zero? That means it's a fraud.


0

Here MaintainableUpgradeabilityProxy is name of contract so what is it returning a contract address? Yes. The difference between doing this and returning an address is that if another contract calls this method, then it will receive that contract instance. It's equivalent to returning the address of the contract and then doing ...


2

Your Javascript code should be asynchronous (either with async/await, or using Promise objects), because both contract.new and object.showNumber return a Promise. For example: async function run() { var contract = eth.contract(ABI); var bytecode = '0xBIN'; var deploy = {from: eth.coinbase, data: bytecode, gas: 2000000}; var object = await ...


0

function balanceOf(address _owner) constant returns (uint256 balance); is the problem I think you must use as follows: function balanceOf(address _owner) public view returns (uint256);


0

Within the Ethereum Virtual Machine, there isn't a way to get the current time, other than the block time. To get current block time stamp we can directly use block.timestamp in solidity. Its returns a time in unix timestamp. Ethereum provides Time unites to facility date computation to a particular level, refer the following document. https://solidity....


0

Cool idea. Yes, a commit-reveal scheme is a primitive from cryptography that is easy to implement on Ethereum using, e.g. the built-in keccak hash function. The salt you mention is also known as a "blinding factor" in cryptography, a randomly chosen value that hides what you noticed is an otherwise deterministic hash value of YES or NO. Your one extra step (...


1

The ecrecover address is: 0x01 Without assembly you can call the ecrecover function like that: function recoverEC_Method1 (bytes32 _hash, bytes32 _r, bytes32 _s, uint8 _v) public pure returns (address) { bytes memory prefix = "\x19Ethereum Signed Message:\n32"; bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, _hash)); return ecrecover(...


1

The following Ethereum web wallets are now seeing increasing use alongside Metamask for various dapps, none of which require installing a chrome extension. Portis Fortmatic Torus Democracy <-- the last one is my project For a comparison of why you might use one wallet over another, and general design considerations that go into making a web wallet, I'...


3

In addition to @mafrasi2's answer, geth ships with a binary called evm. evm compile <filename> can compile "easm" source. You haven't said what sort of assembly you were writing (or given a sample), so I'm not sure if that meets your needs.


1

I've used this assembler in the past, but it's unmaintained and you would need to update it yourself if you want to use any constantinople instructions. I didn't test it, but this one appears to be up to date and a bit more mature. You will have to do some simple preprocessing beforehand, though.


0

I solved my issue the day after I posted here, but I wanted to check if it would work properly before posting in here again. This is the solution that I implemented for my issue. As I said, I need my users to be able and have as many keys as they want. So, In the frontend, they ask for a new Key pair. This is what happens in the background: var keyPair = ...


0

The truffle-assertion package can easily help with this. Once the package is installed you can run the following: // Import the package to your file const truffleAssert = require('truffle-assertions'); // Deploy the contract let testContract = await TestContract.new() // Get the hash of the deployment transaction let txHash = testContract.transactionHash ...


1

In app.js you are initializing contractInstance outside of the 'load' event. window.addEventListener('load', async () => { // ... }); web3.eth.defaultAccount = web3.eth.accounts.givenProvider.selectedAddress; contractInstance = new web3.eth.Contract(abi, '0x15013d783fadAaA9e9d2F0e8d71C575f81a39834'); // Ganache contract address ''...


0

require(Driver[msg.sender] == address(0));


0

The test case for your require statement should be for Drivers[msg.sender] == 0, not for msg.sender == 0 as specified in the title of your question (which by the way is impossible, since you'll need the private key of address 0 in order to generate such transaction). That said, the test case above is really simple - just call the function twice using the ...


0

Yay! Solved - I had to add "constantinopleBlock": 0 to my genesis.json in the "config": { ... } section. It now works - my contract is doubling the input :-) (See: invalid opcode "0x1c" during smart contract method execution)


0

Make the constructor payable too. Refer the following code. constructor() public payable{ owner = msg.sender; }


1

The CREATE2 is a new opcode introduced in the Constantinople update earlier this year. It's otherwise similar to the traditional CREATE opcode which creates a new smart contract but with CREATE2 you can more freely influence the resulting contract address - for example to create a contract to the same address where another contract existed earlier (but which ...


1

The economic mechanism for how transaction network inclusion works will not change. The difference lies in how the network confirms the transactions and arrange blocks and that is a responsibility beared by special nodes. Right now --> this responsibility is placed on 'miners' who arrange and confirms blocks through mining. In Serenity --> This ...


1

What is the time unit for this contract, and the time scale? Is it payment per second, or payment per day? In the UTC time scale seconds are measured by hyperfine oscillations of cesium and days are measured by the rotating earth. In UTC (and only UTC) the duration of one day is not related to the duration of one second. Unix timestamps are, over the long ...


1

There is no security issue when making getter functions, period! A getter function is constant (typically view), hence does not change the state. Therefore, such function cannot yield a security breach by definition. You may have a security issue in some non-constant function which calls some getter function, but that security issue will not be resolved ...


0

However, messages sent to Smart Contracts (SC) aren't signed No. All transactions are signed by an externally owned account (EOA). Transactions sent to contracts are signed by an EOA. A contract runs code, and that might include sending a message to another contract. In this case, the message is not signed because it doesn't need to be signed. The ...


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


Top 50 recent answers are included