Questions tagged [solidity]

Solidity is a language for smart contracts for blockchain technologies like Ethereum. It is designed to compile code for the Ethereum Virtual Machine. Use this tag for questions about programming smart contracts using the Solidity language.

Solidity is an object-oriented language whose syntax is similar to that of ECMAScript, but with static typing, and it is designed to compile to code for the Ethereum Virtual Machine for use in smart contracts in blockchain technologies.

6642 questions
10
votes
2 answers

How Execution price is calculated in Uniswap?

I've already spend few hours trying to understand execution price. I understand the the concept of Mid price as it is the reserve ratio between two pairs. According to Uniswap sdk documentation, Execution price is the ratio of assets sent/received.…
10
votes
3 answers

How to make an API call in solidity?

I have a smart contract that I’m trying to make, it pays out the winners of my League of Legends tournament. However I’m running into an issue. I need to make an API call to get the winner of the match, I have a simple URL that I’ve…
user13637241
10
votes
1 answer

How to send an array of structs from web3js to solidity contract?

I am getting an error when passing (javascript array of objects) from web3js, To solidity function that takes (array of structs) as a parameter. could you help me? below is the code and the error // web3js code let slctedItems = [{name:'item1',…
user13602695
10
votes
3 answers

Solidity - Solidity code to Input JSON Description

I want to compile my ethereum HelloWorld.sol smart contract. In all the tutorials is that you do it like this: var solc = require('solc'); var compiledContract = solc.compile(fs.readFileSync('HelloWorld.sol').toString(); where HelloWorld.sol…
Banana Cake
  • 1,172
  • 1
  • 12
  • 31
10
votes
8 answers

Is it possible to store images on the Ethereum blockchain?

I'm ramping up on learning Solidity, and have some ideas. At the moment I am curious if files/images can be put on the blockchain. I'm thinking an alternative would be some hybrid approach where some stuff is on the blockchain, and some stuff is in…
Nik Hammer-Ellis
  • 1,042
  • 2
  • 9
  • 14
10
votes
2 answers

How can I get the same return value as solidity `abi.encodePacked` in Golang

How can i run abi.encodePacked in golang? in solidity i use keccak256(abi.encodePacked(a, b)) to calc the signature of the params. here is my contract. pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/ECRecovery.sol"; contract…
chengbin du
  • 512
  • 4
  • 13
10
votes
1 answer

Unhandled rejection Error: Invalid JSON RPC response: ""

I am trying to call a method on my ERC20 token contract. I am connecting to 'https://rinkeby.infura.io/' httpProvider. I can call() constant methods but when i want to change the state of the contract by calling send() function i get this mentioned…
sam k
  • 1,048
  • 2
  • 14
  • 22
10
votes
4 answers

How to detect if an Ethereum address is an ERC20 token contract?

If I only get an Ethereum address from the input, is there a way to find out whether it matches the ERC20 token standard?
kaichen
  • 157
  • 1
  • 2
  • 7
9
votes
4 answers

How to send ETH to a contract function with ethers.js?

I am trying to send ETH to a contract function from a web app via metamask and ethers.js. So far I have tried: const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); const splitterManager = new…
Bruce Jayasinghe
  • 173
  • 1
  • 1
  • 7
9
votes
3 answers

Solidity - Invalid BigNumber string (argument="value" value="" code=INVALID_ARGUMENT version=bignumber/5.4.2)

solidity newbie here. when I try to read the value of the people array. I'm getting an error: call to SimpleStorage.people errored: Error encoding arguments: Error: invalid BigNumber string (argument="value" value="" code=INVALID_ARGUMENT…
Xaarth
  • 1,021
  • 3
  • 12
  • 34
9
votes
4 answers

how to withdraw all tokens from the my contract in solidity

Can anyone help me? I created a basic contract.But don't know the withdrawal function.Please help me.Thanks everyone I tried creating a basic function but it doesn't work function withdraw() public { …
learn code
  • 91
  • 1
  • 1
  • 3
9
votes
1 answer

how to calculate percentage in solidity

function splitAmount(uint256 amount) private { a1.transfer(amount.div(2)); a2.transfer(amount.div(2)); } I've seen other threads on this but I feel like over complicate things. With this code the amount is evenly split…
Spacebar
  • 95
  • 1
  • 1
  • 3
9
votes
3 answers

run solidity code after every x amount of time

I am creating a dev application in which after for example every 5 minutes would like to run some code from my erc20 token's smart contract. How can I call that function after every 5 minutes in solidity?
geo10
  • 366
  • 2
  • 11
9
votes
5 answers

Verify and Publish Contract on Etherscan with Imported OpenZeppelin file

I'm currently building a ERC721 compliant contract and have published the contract here: https://ropsten.etherscan.io/address/0xa513bc0a0d3af384fefcd8bbc1cc0c9763307c39 - I'm now attempting to verify and publish the contract source code The start of…
9
votes
4 answers

VScode Solidity extension - not finding openzepplin imports

I'm trying to get started with what should be a very simple Solidity contract but VSCode is giving me a hard time. I'm using Juan Blancos solidity plugin but VSCode cannot find openzepplin imports import…
parliament
  • 21,544
  • 38
  • 148
  • 238