Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

Filter by
Sorted by
Tagged with
1
vote
0answers
34 views

org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received on web3j on Android

I am trying to execute transactions by calling my RegisterNewUser function in the deployed smart contract through Android and I am using Infura. However, when I run, there is an error as seen below : ...
0
votes
0answers
16 views

Implementing Roles using OpenZeppelin's AccessControl.sol

First time poster so please go easy! I'm new to Solidity. Have been programming about 2-3 years & I'm working on an Ethereum supply chain dapp for a college project. I've got to the point where I ...
0
votes
0answers
10 views

what's the difference between assembly part and opcode part in remix?

In the remix, there's compilations details button. When you click, one can see Bytecode and also assembly parts. Bytecode is an object which has object key and opcodes key in it. As far as I can see, ...
0
votes
0answers
18 views

ethereum solidity - gas cost wrong

This is bugging me so much time and spent hours and hours on this, I'd really appreciate your help so much.... // this costs 21394 function test2() external { } // this costs 21507 function ...
0
votes
1answer
25 views

What is the value add of _msgSender helper in openzeppelin

I have a question about openzeppelin _msgSender helper: function _msgSender() internal view virtual returns (address payable) { return msg.sender; } (https://github.com/OpenZeppelin/openzeppelin-...
2
votes
1answer
34 views

What is this allowance check in ERC20 transferFrom implementation

There is something i do not understand in this file: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol function transferFrom(address from, address to, uint value) ...
0
votes
1answer
31 views

How can I call a function that performs a transfer in web3?

I would like to call a function in smart contract using web3. In the function, I perform few transactions. The first method that I tried is await myContract.methods.endAuction().call();. This reverted ...
1
vote
1answer
18 views

Can I use an emoji as part of a string in Solidity?

Can I use an emoji in Solidity?
1
vote
1answer
28 views

How to get the return value of a transaction instead of the transaction receipt in brownie

I have a function in my smart contract called getRandomNumer, and it returns a bytes32. However, in brownie, when I make a transaction it returns the transaction receipt. How do I get the return value?...
0
votes
0answers
18 views

Is it possible for an attacker to exploit contracts that rely on incoming “msg.value”?

I am developing an eth2.0 fuzzer for my masters that has produced some interesting crashes - if these crashes are legitimate I believe I may have found a new vulnerability - otherwise, I still have a ...
0
votes
1answer
10 views

Delete mapping values in solidity?

I created mapping address-> uint and i need to make whole mapping -> uints values set to 0 is it possible?
1
vote
1answer
59 views

How much C++ is needed to write smart contracts?

Solidity seems to be written in C++ so does that mean that smart contracts require some level of C++ programming skills to get by? How much background knowledge is required for writing a simple one or ...
1
vote
1answer
26 views

Ethereum storage - how does this cost happen?

contract A { uint x = 10; function test2() public { x = 0; } } I can see that: Transaction cost is 13204 Execution cost is 5136 How can this be ? I ...
1
vote
0answers
54 views

Ethereum cost - how does it work in memory

This is really bugging me and doesn't seem any article that can help at all. wiki says further the gas costs for using memory: The fee for expanding memory is determined via a subtract-the-integrals ...
1
vote
1answer
20 views

what is expansion cost?

I am trying to understand what expansion cost is. We can see that there's this formula to count the memory cost - Now, It's also said that this formula doesn't include the expansion cost. Can anyone ...
0
votes
1answer
35 views

Connect metamask account to smart contract

I am learning Solidity. I have managed to create sample dapps with Truffle. This sample apps are interacting with a smartcontract with web3js. Each time my dapp calls a smartcontract's function, the ...
0
votes
1answer
14 views

error comparing numbers in smart contract (Big Number)

I am unable to understand when all do we need to convert numbers to bigNumbers for asserting to be equal. In some cases by mistake i missed to convert integer variables to bigNumber and they worked ...
0
votes
1answer
24 views

Perimeter of mocha, waffle and chai

Here is what i've understood (please tell me if i am wrong): Mocha (mochajs.org) is a testing framework Waffle (getwaffle.io) is another testing framework chai: This is not a framework, this is a ...
0
votes
1answer
30 views

Is it possible to predefine 'msg.value' when calling a function in an external contract?

I am new to developing smart contracts and have had some trouble trying to troubleshoot a solution to this problem. I have two smart contracts... Contract X: (The bank - Balance 100 ETH) contract X { ...
0
votes
1answer
17 views

How can I create a similar application to YouTube on Blockchain? What is the cost of it?

How can I create a similar application to YouTube on Blockchain or as a smart contract? What is the cost of it?. I am keen on picking it up as a project. Thank you!
3
votes
2answers
78 views

how can library change state?

I have Very Interesting cases about Libraries. CASE 1: I read the following in the official solidity docs: Library functions can only be called directly (i.e. without the use of DELEGATECALL) if they ...
1
vote
1answer
84 views

Instantiating a smart contract in Uniswap using assembly and create2

I am studying Uniswap source code and there is something I do not understand in this file: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol: This factory can ...
0
votes
0answers
20 views

Transfer token failed due to Gas estimation failed

Have issue transfer token, hope to get support from this. my contract https://rinkeby.etherscan.io/address/0x6D96673922d54108e8eFaFDe191Dc473dCeE709B pragma solidity ^0.5.0; import "github.com/...
0
votes
1answer
14 views

how does library end up in contract?

library C { function a() public returns (uint) { return 15; } } contract A { function a() public returns (uint) { return C.a(); } } This is the code I am using. I ...
0
votes
0answers
17 views

how do i call a constructor from another constructor?

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint supply) public { // ...
0
votes
1answer
19 views

Passing Object to smart contract's payable function

I'm developing a contract where I should be able to pay multiple user's addresses. I'm using TRON blockchain. I can use the TRONIDE developer API to send funds. But they recently shutdown their API ...
0
votes
0answers
11 views

Fetching an inputted contract address's token price

I'm looking to fetch the inputted tokenAddress's token price, from say a uniswap eth pair, and return it. Any idea how to do this? contract Initialise { using SafeMath for uint; mapping(...
0
votes
1answer
28 views

Smart Contracts for the Blind Auctions

In blind auctions from solidity documentation what value should I insert under the bid function?Even I inserted string value,integer value under the bid function but it is showing the error as invalid ...
0
votes
1answer
23 views

Returning a dynamic array of structs

I'm trying to return a dynamic array of structs created on the fly from storage data, similar to how we return ViewModel from DB data in MVC. What is the best way of doing it in Solidity? Tried ...
0
votes
0answers
14 views

Why does my web3 not execute this smart contract function?

Good day, I am busy with a small project trying to call a buy() function on an Ethereum Smart Contract. This Contract is found on the Ropsten Test Network here:https://ropsten.etherscan.io/address/...
1
vote
1answer
45 views

ERC20 optimization

I am studying popular Ethereum smartcontract's source code and there is something i do not understand on ERC20 standard. Let's took this example: https://github.com/OpenZeppelin/openzeppelin-contracts/...
1
vote
1answer
17 views

Declaring function with the same name but different arguments in a derived contract [closed]

What happens if one declares a function with the same name as a function in a base contract, but with different arguments in a derived contract? How does it behave with different combinations of ...
0
votes
2answers
97 views

Uniswap V2 Router, Factory on Rinkeby testnet

Is it possible to use Uniswap V2 router on rinkeby? What is the contract address of a router? i found only factory contract address ?
0
votes
0answers
24 views

Solidity contract: How to deal with return parameters in solidity

i am having an issue with an function I would like to call. Following case: The function looks like this: Params Type token0 IERC20 token1 IERC20 amount uint256 parts uint256 flags uint256 and ...
1
vote
1answer
24 views

registerInterface and parent constructors in Solidity

The openzeppelin ERC721.sol file contains the following code: constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _registerInterface(...
0
votes
1answer
147 views

Ethers.js testing: Giving hardhat generated accounts ETH

Deployment √ Should set the contract's address as owner (44ms) √ Should assign the totalSupply of credits to the creditsContract (114ms) Transactions 1) Should fail if sender ...
0
votes
1answer
22 views

What happens if there is no fallback function in solidity?

Here is the short definition about fallback function in solidity: Solidity fallback function does not have any arguments, has external visibility and does not return anything. What happens if there ...
0
votes
0answers
13 views

“Revert: VM Exception while processing transaction” while trying to swap with 1Inch

since a while I am trying to program a swap contract for 1Inch. The problem is that I always get a Revert message when trying to call the function. I made sure that the contract has enough funds from ...
0
votes
0answers
4 views

Truffle testing:How to convert from Mocha to Solidity

I am following the tutorial at: truffle- Mocha It shows a mocha code for testing. I want to do the testing in Solidity. const SimpleContract = artifacts.require("SimpleContract"); contract(...
0
votes
1answer
138 views

Truffle migrate shows an error on open zeppelin ERC721

I'm very new to truffle and solidity it might be a rookie mistake. When typing truffle migrate --reset, I've got the follow errors : @openzeppelin/contracts/introspection/ERC165.sol:24:5: Warning: ...
0
votes
0answers
80 views

Uniswap: error IDENTICAL_ADDRESSES in function swapExactTokensForETH when swapping WETH to ETH

I am using Uniswap's interface Router02 and have been able to execute all swap functions correctly with one specific exception: swap WETH to ETH. In the contract below, function swapExactTokensForETH()...
0
votes
1answer
26 views

Why chainid is done in assembly in UniswapV2ERC20

I am studying uniswap solidity source code and there is something i do not understand in UniswapV2ERC20 constructor: uint chainId; assembly { chainId := chainid } (pasted from https://github.com/...
0
votes
1answer
31 views

Web3 1.3 Contract method call returns empty string

I am new to solidity and I am facing a strange issue. I have created the following Contract: pragma solidity >=0.7.0 <=0.8.0; //SPDX-License-Identifier: UNLICENSED contract Lottery{ ...
0
votes
1answer
24 views

The “from” field has been defined when sending a transaction, but the error still occurs

Problem I am following this tutorial on how to make a donate button on my React app. The tutorial is in HTML, however, so below is my attempt at converting it to ReactJS. Code App.jsx donate = () =>...
0
votes
0answers
18 views

documentation of API functions in Solidity

I would like to find some URL (or something), for the documentation of API functions in Solidity. For instance: where can I get the information for the Solidity "CALL" function? and know ...
1
vote
1answer
29 views

Solidity - Proper way to Import Contracts

When importing one Solidity contract into another, what’s the difference between importing it and accessing it using the is keyword, vs. importing it and just instantiating an object of it? Here’s ...
0
votes
1answer
23 views

Expected primary expression error in pragma solidity ^0.8.0

I am trying to use any of the uint to string function implementations from the below links. How to convert uint to string in solidity? How to convert string to int Conversion of uint to string However ...
0
votes
0answers
14 views

How to use web3 when one smart contract is interfacing with another?

A few months back I posted this question on this form. Since then, I've used the interface method to make my smart contracts interact together. I didn't have any problem while testing and developing ...
0
votes
1answer
27 views

What is the difference between the abstract and virtual keywords in Solidity?

Solidity has the keywords abstract and virtual. What is the difference?
0
votes
1answer
21 views

How can I automate smart contract interaction

I've deployed a smart contract to the blockchain with few functions. I want to know how I can interact with the code e.g. > Contract has 2 functions - deposit and withdraw. Now, instead of me ...

1
3 4
5
6 7
192