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.

0
votes
1answer
10 views

Why 'throw' is a problem in this Solidity code?

I found this code at the following site: Ethereum Griefing Wallets for (uint i=0; i<investors.length; i++) { if (investors[i].invested == min_investment) { // Refund, and check for failure. ...
0
votes
2answers
26 views

Finding a better way to retrieve information about struct

I've run into a problem about getting information about the structs. The code is written below: pragma solidity ^0.4.23; contract Transport { address public manager; Batch[] public ...
0
votes
0answers
25 views

Why am I getting the error "Expected pragma, import directive or contract/interface/library definition?

I have "pragma solidity ^0.5.9" at the start of the file yet I still get this error. Listing.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition. ...
2
votes
1answer
24 views

Documenting Smart Contracts and Dapps - community standards and tools

Do you guys know of any kind of documentation standards that are widely used within the Ethereum community? Any kind of documentation tools will also be of great help. Thanks in advance.
2
votes
2answers
110 views

Is my ethereum solidity contract correct and safe

I am very new using Solidity to create Ethereum contracts and would like to know if the contract I have created is first correct and safe to use. What I am doing in this contract is allowing the user ...
0
votes
1answer
21 views

In node.js event is not fired

I am using web socket to get event. sending transaction works fine. but event is not fired. also I referred Web3 events not working but it does not work, too. I used eventemitter also. but it did ...
0
votes
1answer
43 views

what does external means ? how can i call the test2() inside my class

pragma solidity ^0.5.7; contract Test { function test() public view returns (uint){ return 10*10; } function test2() external view returns (uint){ ...
1
vote
1answer
21 views

How to test events that were sent by inner transaction / delegate call?

Usually, using truffle I can check for events like this: let { logs } = await myContract.doSomethingImportant( xxx ); // 1500 tokens are expected to get expectEvent.inLogs(logs, '...
2
votes
1answer
25 views

Finding an element in array

pragma solidity ^0.4.17; contract Transport { address public manager; Car[] public carArray; Bike[] public bikeArray; struct Car { uint carId; address carOwner; } ...
1
vote
1answer
40 views

Solidity Error Address / Address Payable

I'm currently learning solidity programming to create a basic smart contract based on a 2018 tutorial where solidity was using version 4. I'm currently using truffle v5.0.21. I understand that there ...
1
vote
1answer
23 views

Newbie. Getting cannot read property 'abi' of undefined when trying to deploy on Ubuntu

let abi = compiled.contracts.example.PartyTime.abi; This is the line of code that is causing the error. I copied the abi code from Remix into an abi.json file. But it doesn't seem to be reading it ...
2
votes
0answers
31 views

How the following pairing equality be verified in Etherum Smart contracts?

I have found available precompiled contracts in solidity. For example, this answer enter link description here points out a precompiled contract that can verify BLS signature. However, looking to the ...
1
vote
1answer
11 views

Was testing this code I found online but keep getting errors?

pragma solidity ^0.5.0; contract Courses { struct Instructor { uint age; string fName; string lName; } mapping (address => Instructor) instructors; address[] public instructorAccts; ...
2
votes
2answers
17 views

What is the latest implementation of approveAndCall() - Solidity ˆ0.5.0

Just curious for some background on approveAndCall() 1) Is it initially an ERC223 method ? or is it officially part of the ERC20 interface ? 2) Also Im working with an old contract so Im wondering ...
1
vote
1answer
19 views

I've given Gwei less than 0.1 for a transaction, and it's been an hour, and it is not showing up in etherscan!

I know I pretty much messed up with Gwei, I've given it < 0.1. My doubt is if the transaction gets failed will the funds get back to my wallet or lost forever and how much time will it take for the ...
1
vote
1answer
38 views

After EIP 198 introduction, how much gas is required for RSA signature verification in solidity?

Thanks to the introduction of EIP 198, RSA signature verification is now feasible in Ethereum. How much gas is required for such a verification?
3
votes
1answer
24 views

Compilation error using SafeMath

I am trying to do subtraction operation using the SafeMath library. The following is my code: pragma solidity ^0.5.1; library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (...
1
vote
1answer
21 views

Infura event listening [duplicate]

I am using Infura, Ropsten Test network, Web3@0.20 in the back-end of my Express website. I want to listen events in my ERC20 contract. I tried a lot of methods, but still failed. How do I revise it? ...
4
votes
1answer
27 views

Timestamp in Ethereum

I have a smart contract where the user inputs temperature readings, I'd like to add a time stamp to relate those reading with a current time of submission. I understand that in Ethereum we only have ...
1
vote
2answers
42 views

Storage/Retrieval of mapped structure data

I want to store the structure data in a mapping i.e. if I have a student structure as described below, then I should be able to have a myriad of students and distinguish between them using wallet ...
1
vote
0answers
10 views

Problem connecting web3 via websocket to node with nginx

we are trying to connect to a geth node via WebSockets to be able to subscribe to contract events. This node is created with docker and this docker uses nginx as a proxy. We can connect easily with ...
0
votes
1answer
13 views

Why do my events not emit the correct value?

When testing a contract with Truffle, I have found that the variables that are emitted by the event do not match the values that are passed into the event emission. Why does the event not return the ...
0
votes
1answer
30 views

a smart contract deploying another one

I am working on a crowdfundin dapp and I have a problem while deploying a smart contract from another one. Actually , the main smart contract called crowdFactory is supposed to invoke a smart ...
0
votes
2answers
34 views

Operator & not compatible with types bytes32 and int_const

i have the code below: uint256 lastBlockNumber = block.number - 1; bytes32 hashVal = bytes32(block.blockhash(lastBlockNumber)); bytes5 _byteData = bytes5((hashVal & 0xffffffff) <&...
1
vote
1answer
24 views

Error encoding arguments: SyntaxError: Unexpected token e in JSON at position 2 while string concatenation

I am just adding 2 strings into one string but getting below error: transact to TestStrings.testCOntract errored: Error encoding arguments: SyntaxError: Unexpected token e in JSON at position 2 ...
0
votes
1answer
28 views

How to test the fuctionality of a Bittrex-related smart contract?

I've got my hands on a smart contract related to the Bittrex exchange. I would like to deploy this smart contract to test the functionality but I don't know how to call the functions properly. My ...
1
vote
0answers
26 views

Solidity: TypeError: Member “unbond” not unique after argument-dependent lookup in contract super EthGatedMarket

I'm getting this error: TypeError: Member "unbond" not unique after argument-dependent lookup in contract super EthGatedMarket. super.unbond(msg.sender, gatewaySpecifier, quantity); ^----------...
3
votes
1answer
23 views

Matrix multiplication in solidity

I am trying to implement an algorithm requiring matrix multiplication. I know I can program this in the rudimentary way similar to doing the process by hand, but I am worried about the computational ...
0
votes
0answers
35 views

cannot unmarshal hex string of odd length into Go value of type hexutil.Bytes?

const Tx = require('ethereumjs-tx').Transaction; const Web3 = require('web3'); const web3 = new Web3('https://ropsten.infura.io/161d7c8443f14babb3c176023628a055'); // console.log(web3.eth.accounts....
1
vote
0answers
10 views

DApp BPMN architecture design [closed]

I want to design my dApp on Ethereum but i want to explain the application logic (smart contracts) through BPMN to explicit my decentralized exchange.. Can someone help to design my decentralized ...
1
vote
2answers
27 views

Set the price by calling another contract and getting result from it

I want to set the price in Token every time the contract is deployed by calling ETHUSD in constructor and getting result from it. pragma solidity ^0.5.0; import "./ETHUSD.sol"; contract Token { ...
1
vote
1answer
37 views

Errors in when compiling the BLS signature in remix?

Etherum can verify BLS signatures, In this answer Does Ethereum support pairing operations? There is an example of how to verify BLS in solidity. However, when I tried to test the code in remix, ...
0
votes
1answer
31 views

How do we communicate with contract functionality which is deployed in public test network using web3j [on hold]

I would like to write a wepapp for security token contract which is deployed in public Ropsten Test Network using web3j. Need some idea. Thanks in Advance
0
votes
1answer
38 views

Passing a storage pointer to a struct as an argument

What kind of solidity functions can one pass a storage pointer to a struct as an argument? Say between public and private functions or internal and external functions?
1
vote
0answers
16 views

delegatecall (assembly) didn't change state variable in Remix with Web3 Provider

I am trying to test proxy pattern in Remix, which connected to my private chain with Web3 Provider. By the way, miner is working all the time. After invoking add function of Proxy contract, the state ...
1
vote
1answer
41 views

How to measure size of stored data in the blockchain?

I know that remix can measure the execution cost and transaction cost. I want to measure the storage overhead ( Size of data in Bytes) on creating a contract on the etherum blockchain or calling a ...
1
vote
1answer
28 views

Crowdsale, how to calculate hard cap?

I was reading this article about Crowdsale. Simply, 100 Tokens are to be minted. The author set 60% of tokens are distributed as public sale. To be more specific, 20 out of 60 tokens will be sold ...
0
votes
0answers
12 views

How can I use the parameters of an event as a function input?

how can I use the indexed parameter of a triggered event as a input for a function called in response to that event triggered? This is the event: event LogOfferAccepted( uint _id, ...
1
vote
1answer
17 views

Why are integers returning as hex?

I am implementing a simple smart contract in Solidity 0.5.9. One of the functions is called getSummary() which basically returns a summarized version of a vote: function getSummary() public view ...
0
votes
1answer
21 views

Compilation Error: Error: Expected identifier but got '(' msg.sender.transfer(uint(amount));

I am compiling the following code on solc & remix ide: pragma solidity ^0.5.1; contract Signed1 { uint val= 0; function withdrawOnce(int amount) public returns (uint){ ...
0
votes
1answer
27 views

extract address of used library

Is there anyway or method to extract the address of a linked library from the contract bytecode (not a verified contract code) or deployment transaction? my question is about step 3: step 1. ...
0
votes
1answer
24 views

condition check of struct mapping in solidity?

struct User { string username; string password; address userid; bool isAdmin; } mapping (uint => User) users; function checkIfUserExists(address userid) public ...
2
votes
1answer
20 views

What happens to immutable contracts when Ethereum 2.0 will likely change the 15s block time?

Immutable contracts that need to have a time system for handling their functions process are mostly based on block.number system. They assume there is about 15seconds between each block and thus ...
-1
votes
0answers
23 views

How to create a security token in ethereum ropsten testnetwok

I want to create a security token like ST-20 in ethereum. where i could start.Any suggestion
2
votes
2answers
105 views

Verifying Modular exponentiation operation in etherum

I have Alice who should do some cryptographic operations off-chain. Then a smart contact has to verify equality by performing Modular exponentiation operation. I attached an image of the off-chain ...
1
vote
1answer
30 views

ERC721: Interface ID Registration

Why we need to register Interface ID in ERC721 token. I was just going through the openzeppelin-solidity erc721 code and curious to know that why we need to use this. That interface id register code ...
0
votes
1answer
26 views

Updating ERC20 Contract from 0.4.0 to 0.6.0

Im updating some ERC20 contact code from solidity 0.4.0 to 0.6.0 and hitting some snags as it seems openzeppeling has changed its structure since then as can be expected. I cant access the balances ...
0
votes
1answer
26 views

Remix - Pass bytesX to function

Using Remix, I can't pass a set of bytes ["0xee", "0xff", "0xgg", "0xhh", "0xii"] to my function function foo(bytes5 input) { // Do something } I've already tried all these formats: ["0xee", "...
0
votes
2answers
46 views

Solidity: “send” and “transfer” are only available for objects of type “address payable”, not “address” [duplicate]

I'm trying to compile my smart contract with the solidity version 0.5.0. with the code below: function unbond(address wallet, bytes32 specifier, uint quantity) internal { bondage = ...
0
votes
1answer
56 views

Solidity: Convert from “bytes memory” to “address”

I'm using solidity 0.5.0 and when i try to compile my contract it's giving me this error Explicit type conversion not allowed from "bytes memory" to "address" my code is this: /// @dev get broker ...