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
13
votes
2 answers

How to receive and send USDT in a smart contract?

Is there any guide or code that can serve as an example to implement the functionality where a smart contract receives and sends USDT to other addresses. I appreciate your help
jeissoni22
  • 285
  • 1
  • 2
  • 11
13
votes
4 answers

Error: The method eth_sendTransaction does not exist/is not available

Showing an error while calling solidity contract, which is deployed already in ropsten-infura. I'm using web3(@0.19.1) for calling contract. Anybody faced the same issue?
Aditya V
  • 548
  • 2
  • 8
  • 17
13
votes
3 answers

How can I return an array of struct in solidity?

I am designing a solution for an ethereum smart contract that does bidding. The use-case includes reserving a name eg. "myName" and assigning to an address. And then, people can bid for that name (in this case myName). There can be multiple such…
13
votes
1 answer

who is the owner of the contracts deployed using truffle?

I am using testrpc and truffle to test my contract. When I type truffle migrate , this will deploy my contract to the testrpc network. My question is , which account (from testrpc accounts) has been used to deploy the contract. In other word, whose…
sheemar
  • 467
  • 3
  • 13
12
votes
4 answers

How to return array of address in solidity?

I am creating a smart contract in solidity ^0.5.1 in which I get the following error: data location must be a memory for the return parameter in the function, but none was given. In the below function I am getting error. function getCitizen()public…
harsh
  • 337
  • 1
  • 2
  • 14
12
votes
3 answers

Solidity error: Expected identifier, got 'LParen'

I'm getting the error: Expected identifier, got 'LParen' Problem is, this code is from the Solidity docs! I have tried many thing for this error but to no avail. The link where I got the code is:…
KVISH
  • 12,923
  • 17
  • 86
  • 162
12
votes
3 answers

web3 websocket connection prevents node process from exiting

I have a node js process that creates a web3 websocket connection, like so: web3 = new Web3('ws://localhost:7545') When the process completes (I send it a SIGTERM), it does not exit, but rather hangs forever with no console output. I registered a…
Andy Pang
  • 387
  • 4
  • 10
12
votes
9 answers

Event triggering in solidity

I'm currently working on ethereum platform(node.js and solidity). My question is how do I trigger an event in solidity(contract) using node.js?
Yajnesh Rai
  • 290
  • 1
  • 6
  • 17
11
votes
4 answers

Error: Failed to fetch the Solidity compiler

I am new to Truffle and going through the Metacoin tutorial; I followed all the steps but when I do truffle compile, I get the following: Error: Failed to fetch the Solidity compiler from the following locations:…
Emily Kuo
  • 121
  • 1
  • 5
11
votes
6 answers

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify - with arguments

I am trying to verify my contract with arguments and I am getting this error: Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify I am also importing Open Zeppelin contracts…
solidityguy
  • 199
  • 1
  • 3
  • 8
11
votes
3 answers

What is difference between internal and private in Solidity?

In Solidity we have four types of access. Two of them are private and internal. What is the difference if both of them can be used inside smart contract and both of them are not visible after deploying?
Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51
11
votes
5 answers

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity ^0.8.0”

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity ^0.8.0” Here is a photo of the error - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7 All my contracts are using the ^0.8.0 pragma. My…
Palm
  • 360
  • 2
  • 17
11
votes
2 answers

Solidity: How to represent bytes32 as string

This may be simple in other languages but I can't figure out how to do it in Solidity. I have a bytes32 like this 0x05416460deb76d57af601be17e777b93592d8d4d4a4096c57876a91c84f4a712. I don't want to convert the bytes to a string, rather I just want…
chnski
  • 557
  • 1
  • 4
  • 20
11
votes
8 answers

How to correctly import SafeMath.sol into contract

This has been a problem I've been dealing with for a while now. My temporary solution has been to create a SafeMath.sol file in my Contracts directory and directly import it from there. However, I've been looking for a 'clearer solution' to this...…
Brennan
  • 355
  • 1
  • 5
  • 10
11
votes
4 answers

Does Solidity supports floating point number

I am new in solidity language. Have seen their documentation. Is there any floating point data type ?
Anijit Sau
  • 555
  • 2
  • 8
  • 25