New answers tagged

0

Actually, the call does not use gas. However, it seems to be calculating gas in the truffle console. In truffle-config.js, set a larger number in networks.kovan.gas as in the example below. ropsten example) networks: { ... ropsten: { ... gas: 5500000, ... } },


0

Your OnlyContract() modifier checks the msg.sender and requires address(this). When Malicious delegatecalls, the context is Malicious which is to say that OnlyContract will not be fooled - it will see the foreign address, not its own. Contract A ----- delegates ----> Contract B ---- calls ----> Contract C ---> msg.sender = A function delegateToB() ....


0

Possibly a kind soul with more knowledge of v8 compiler optimization will chime in. This will be a general observation. storage is cheaper. Why? That's a misleading conclusion because you read from storage in both cases. TestVars storage v = vals; TestVars memory v = vals; What you do with it (left side) differs. In the storage case, you set a storage ...


0

try this to check if the credentials are correct and has balance System.out.println(credentials.getAddress()); BigInteger balance = web3.ethGetBalance(credentials.getAddress(), DefaultBlockParameterName.LATEST).send() .getBalance(); System.out.println(String.valueOf(balance.intValue()));


0

Before following the procedure, open in you wallet the address where you know that you have to be claimed UNI tokens Go to UNISWAP app : https://app.uniswap.org/#/swap Click on 3 dots menu to the top left side of the page. Then in the menu click on Claim UNI option. Enter your Instadapp wallet address in the recipient input box and click on Claim UNI ...


1

I've been using such a method and it's safe and also saves some gas. Just why don't you use the transfer() method instead of all that logic? function sendMultiple(address[] memory _redemptions, uint[] memory _values) public returns (bool) { require(_redemptions.length == _values.length); uint256 length = _redemptions.length; for (uint i = 0; ...


1

It's not madness. On-chain deployment patterns are one way to establish trust between separate contracts. But, you are running into a classic problem. When a contract A deploys another contract B, the bytecode for contract B gets rolled up into the bytecode for contract A. This is so contract A knows what to do. Reducing the size of the deployed contract is ...


0

First of all in contract CoinFlip you need to have the following method in order to allow the incoming ether transfers: receive() external payable {} Secondly method beforeAll in contract CoinFlipTest is failing, because when you are creating the instance of contract CoinFlip you're not passing ethers to it and you have the following condition in the ...


2

Just to add to Shane's good answer: In Python and other languages this variable type is called a tuple. In Solidity they're not considered a proper type, but can be used as a shorthand. See the docs: Destructuring Assignments and Returning Multiple Values


2

If I understand what you are asking, you are wondering what (bool success, bytes memory data) are. In Solidity, a call (or delegatecall) returns two values that describe the status and result of the call. The first return value is a bool that states whether a call was successful or unsuccessful. The second parameter is the return data of the call, usually ...


0

Trying the Solidity code on my local environment running go-ethereum, it worked just fine. It may sound dumb but after you altered the smart contract code and re-deployed it, did you add files to the storage? Because it's a new smart contract, new address, new storage. Myself, I got rid of Ganache because it was acting different that the production network (...


1

The one who mines the block decides the sequence of its transactions. Usually the order is decided by the transactions' gas prices (default logic for most miners). In that case, users may influence it by "speeding up" the transaction, meaning: re-broadcast the transaction with a higher gas price.


1

Some remarks: Usually commit and reveal phases are separated such that no commit message are allowed after certain point. That way if someone send a reveal message an attacker no longer can send a commit with the answer. The committed message must include something extra that an attacker cannot alter like msg.sender or something he cannot guess like a ...


2

Question 1: What do you think ? Am I right about Solution above ? Agree. To prevent front-running, use a factor like msg.sender in the hash function so the front-runner can know the secret and still be unable to use that knowledge. For example, consider a piggy bank with a secret word that releases the money. If the withdraw function uses (pseudo) hash(...


0

Are there any other solutions Can't say definitively that there isn't another solution but the core problem boils down to this. If it is possible for the contract to use any form of deduction whatsoever to deduce the result then the result is calculable by everyone which clearly defeats the secrecy goal. This is the generalized problem that commit/reveal ...


1

When you declare an enum, each element is assigned an integer sequentially. In your case: rock = 0 paper = 1 scissors = 2 Not sure why you want to pass this enum in the constructor, but if you want to implement a commit-reveal scheme, you should have at least commit() and reveal() functions where you pass the player's move, and you probably need also ...


0

If the malicious owner sees the hash you submitted and submits the same hash, your solution breaks down. Commit-reveal can be used only if it is hidden when committing and open when revealing. When committing, there are so many people who have committed it, so it should be difficult to know who's right. A suitable example of commit-reveal is to answer a quiz ...


0

Truffle compiles everything, including those imported. The imported SafeMath is included in your contract, and only your contract is distributed. It refers to the deployed contract by setting the deployed contract address as an argument of AggregatorV3Interface.


1

Using the ERC20 standard as it is cannot solve this problem. Refer to the link below for a proposal to change the ERC20 API to prevent this problem. https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/edit Commit-reveal is a solution to a front running attack, but its use is slightly different. Even if you commit-reveal your ...


0

You can do this in 2 transactions first approve for zero tokens, wait for that transaction to go through approve again for 50 tokens.


0

You have to first create these contracts in order to get their address, change this: contract C { address a = address(A); address b = address(B); } To this: contract C { address a = address(new A()); address b = address(new B()); } Then you can read them like this: function getContractAddresses() view public returns(address, address) { ...


0

View Smart Contract Function Calls With Bloxy Search for the smart contract using its' address with Bloxy. i.e. 1inch smart contract address: 0x111111111117dC0aa78b770fA6A738034120C302 Scroll down to the Smart Contract Function Calls section to view all smart contract function calls made. FYI - It seems 1inch never called renounceOwnership, therefore an ...


1

In theory, yes you could by learning the language of Ethereum smart contracts, Solidity. In practice, if you don't already know how to code, you will have a hard time understanding Solidity. It has its own quirks and there is not much documentation available. It would be much easier to learn another language first to learn how to code (I would suggest Ruby ...


0

Most of the ZKP frameworks such as Zokrates, Circom, SnarkJS, gNARK etc. are designed for creating circuits, quadratic arithmetic programs and internal representations. Zinc is a fresh attempt to bring smart contracts to the ZKP frameworks with good guarantee for safety and security. It is constructed as a smart contract language optimized for ZKP circuits.


1

Technically speaking what you propose is possible. Perhaps I would leave the two functions swapExactETHForTokens & swapExactTokensForETH as they are, and I would create a new function to call them in a single transaction in order to adjust the function parameters as needed. However, if your goal is to do arbitrage in order to make some profit, you should ...


1

Your issue is that you are trying to read an array slot that does not yet exist. You need to push the value to _users[friend].requests instead of setting it as you are doing now. To resolve your issue, you can change: _users[friend].requests[0]=msg.sender; to _users[friend].requests.push(msg.sender);


1

You can delete an array to achieve your goal. See the following code as an example. pragma solidity 0.6.12; contract Test { uint256[] public bidderItemID; function setBidderItemID() public { bidderItemID = [1,2,3]; } function deleteBidderItemID() public { delete bidderItemID; } }


0

you can import with github. https://remix-ide.readthedocs.io/en/latest/import.html ie: pragma solidity ^0.7.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0-solc-0.7/contracts/token/ERC20/ERC20.sol"; contract Token is ERC20 { constructor () ERC20("Token", "TKN") { _mint(msg.sender, ...


1

They have a video how to setup a time node https://blog.chronologic.network/how-to-prove-day-ownership-to-be-a-timenode-3dc1333c74ef. A timenode is a separate application from regular ethereum clients (geth, parity, besu, etc). A timenode is configured with an account that will be used to send transactions.


6

"Technological limits" is a quite broad term, but some other relevant limits are, for example: Maximum contract size of 24 kB (see in this article) Limited stack depth of 1024 (see deprecated Call Depth Attack) And most importantly, every computation requires gas, which is limited by your gas limit (see gas costs for EVM instructions) For a more ...


2

Not sure what you mean by "Can I pay for a service on my backend to run on a certain date?" What I understood from your question i.e "I want a function on the smart contract to run on a certain date." Yes you can run smart contract functions at a certain datetime. For that you have to run Cron Job in the back end, you can use NodeJs ...


0

This codehash is created using the UniswapV2Factory function pairCodeHash()


1

Stack in Solidity means same as it means in any other machine or virtual machine. Stack is being allocated for call return addresses, function arguments and local variables. Besides limited by gas consumption, transactions are limited by stack size and cannot push more than 1024 EVM words on the stack. Probably the easiest place to study the stack usage in ...


1

By reading at the contract, there are essentially two roles: > Seller: this is assigned inside the constructor, meaning that only the person who deployed this contract becomes a seller: constructor() payable { seller = payable(msg.sender); // Contract creator becomes seller value = msg.value / 2; require((2 * value) == msg.value, "Value ...


0

You probably don't need to create a contract for every new product, as this would be expensive in terms of gas consumption. You can try something like this: // SPDX-License-Identifier: MIT pragma solidity 0.8.1; contract ManageProduct { struct Product { string name; uint256 price; } Product[] public products; ...


3

I updated your code with examples of creating array of contracts, passing data and reading that: pragma solidity ^0.6.0; contract Item { uint public blabla1; uint public blabla2; constructor(uint _blabla1, uint _blabla2) public { blabla1 = _blabla1; blabla2 = _blabla2; } function returnData() view ...


2

This touches several parts of how Ethereum works. I'll try to explain it in an understandable way: 1.) Ethereum has "externally owned accounts" (EOAs) and "contract accounts". EOAs are much like normal bank accounts. They have an address (IBAN) and a balance (in Ether). Essentially, the EOAs owner possesses a public key pair, of which ...


1

An EOA has always a private key to sign the transactions. So if you plan to use one common EOA (your backend manager) then the sender of all transactions would be that EOA - and that one would also pay all gas fees. If you wish to get some Ethereum assets (either Ethers or some tokens) from the users as payments, the users need their own wallets (EOA) from ...


0

A smart-contract is a passive software object that, on its own initiative, cannot request anything from anyone. A smart-contract is activated by a transaction sent to its address. The smart-contract cannot directly request anything on the Node, but it can emit an Event containing the request required for the smart-contract. The corresponding Node catch the ...


Top 50 recent answers are included