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
2
votes
1answer
43 views

node cannot be made up in private blockchain by using command line

I have created the genesis.json The genesis json content is { "config": { "chainId": 46860, "homesteadBlock": 1, "eip150Block": 2, "eip150Hash": "...
0
votes
2answers
25 views

Fetching stored values for use in function logic

Are there any benefits from fetching stored data into other functions by calling a function to call a private variable, instead of calling the private variable directly? What is best practices? ...
0
votes
0answers
25 views

Github Clone Website [migrated]

We're asked to create a Github clone website as an assignment in our college Our implementation should upload the code on an online storage like IPFS and we should track the commit hashes on the ...
0
votes
0answers
22 views

invalid jump destination error in a contract execution

I am trying to swap dai to eth in Rinkeby testnet using the Uniswap smart contracts. I get the invalid jump destination error and the transaction fails. I do have enough ether in my account. Any ...
0
votes
0answers
26 views

Create lots of hashes with ID

I have this code to create hash. function getUniqueHash(address _hashunique) public view returns (address) { bytes20 b = bytes20(keccak256(msg.sender, block.timestamp)); uint ...
0
votes
1answer
15 views

Is it possible to instantiate a deployed contract in js using contract address alone? without copying abi data?

Is it possible to instantiate a deployed contract in js(dapp) using contract address alone? without copying abi data?
1
vote
1answer
30 views

Implementing ERC721 Marketplace

I'm working on a project where I need to implement an ERC721 marketplace. It doesn't work for some reason and wanted to know if I'm doing everything correctly. The way I approached this was: The ...
0
votes
3answers
22 views

Struct creates instances with zero values for all of it properties instead of using function arguments

Inside my smart contract I have a struct type NotaryEntry and a function addNotaryEntry which creates an instance of the struct and add to a mapping, I do pass the right values to the function but the ...
0
votes
2answers
23 views

do users should be aware of smart contract of the dApp they are using?

So dApps are frontend + contract. Users interact with smart contracts via frontend. Do users i.e. people should be aware of how the contract is designed while using any dApp? are their any risks of ...
0
votes
1answer
35 views

'ALERT: Trying to call a function on a non-contract address' Why Do I Keeping This Error?

This is the error from metamask directly: This is the error I get once after I submit the information to IPFS: My Smart Contract: pragma solidity 0.5.3; //Imports for safe math operations import "...
0
votes
1answer
38 views

I can't execute transaction from Dapp: Nounce too low

I'am trying to use go-ethereum on my local network: I have configured a 5-node quorum network on my local machine and I'am building Dapp. I created smart contract and generated go bindings. When I ...
0
votes
1answer
35 views

Split smart-contract

We are developing a decentralized application on Ethereum that manages surveys. We have a main smart-contract that contains survey information (i.e. hashes) as well as 2 main functions: one to create ...
0
votes
1answer
36 views

create ERC-20 token from a contract function

I would like to do a function create contract with ERC-20 interface. But I have a few problems. If anyone help me I’ll be appreciated. Here’s the code : pragma solidity ^0.5.0; import 'https://...
0
votes
1answer
17 views

How to request tokens from msg.sender within contract function

transferring ethereum from the user of your smart contract is simple enough, you simply use msg.value and can use this within your contract's functions. But doing the same thing with tokens is a bit ...
1
vote
1answer
28 views

ERC721TokenReceiver, assuming that transfer function exists?

When trying to find out if a contract implemented onERC721Received from safeTransferFrom function, are we just safely assuming the contract has all the erc721 related functionalities? such as transfer,...
0
votes
1answer
30 views

create contract from function / contract

**Hey guys ! I just try to make a contract for create a contract. It supposed to be ERC-20 interface so my first contract for this. But I don’t know how can I do _mint and createContract functions ...
0
votes
0answers
19 views

Web3.js doesn't fire event callbacks anymore

I have a small dapp that uses web3.js to interact with a contract. I have one event listener: let activateEvent = nexusContract.events.Activate({ _member: defaultAccount }) activateEvent.watch((...
0
votes
0answers
6 views

console.log(App.ticTacToeInstance.events); in createNewgame function getting undefined

import Web3 from "web3"; import { default as contract } from 'truffle-contract' import ticTacToeArtifact from "../../build/contracts/TicTacToe.json"; import $ from "jquery"; let TicTacToe = ...
0
votes
0answers
16 views

Error using drizzle and react

My contract Storage.sol - pragma solidity ^0.5.0; contract Storage { string public data; function getData() view external returns(string memory) { return data; } function setData(...
0
votes
0answers
20 views

Why do I get a bad instruction in the transaction?

Here is my withdraw dividend code : function WithdrawDividend(address) public { if (!_RestrictedFromDividend[address(msg.sender)]) { _SavedDividend[msg.sender] = _balances[address(...
0
votes
1answer
54 views

html:82 Uncaught ReferenceError: App is not defined at HTMLButtonElement.onclick (html:82)

It's showing me uncaught reference error in my index.html file <div id="candidate-box"></div> <button class="btn btn-primary" onclick="App.vote()">Vote</button> ...
1
vote
1answer
21 views

Assert.equals() weird behavior does not recognize (apparently) equal strings

I'm facing problems related to string comparison using Assert.equals() provided by remix_tests.sol. I made a toy contract and a related test to show what the problem is: https://gist.github.com/...
0
votes
1answer
28 views

I don't understand why my function is not working

I have a read function to check whether someone should go and use the write MakeEligible function. Here is the code: function ShouldIMakeMyselfEligible(address) public view returns (bool) { if (...
0
votes
1answer
36 views

Problem: Values from a transaction(web3) are not stored in datastucture defined by Solidity

First of all i use Truffle and Ganache. I made a smart contract with solidity defining the following structures: struct TimestampproTeil { uint Fahrwerk; uint Chaussy; uint Kabine; ...
1
vote
1answer
20 views

bytes data param in safeTransferFrom

In ERC721, safeTransferFrom has bytes data parameter. function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) public; how do I send data (is it in hex format?) and what ...
0
votes
1answer
28 views

Mapping not updating after function is called

After calling this function: function WithdrawDividend(uint256 value) public { require(value <= _balances[msg.sender]); if (_RestrictedFromDividend[address(msg.sender)] <= 0) { ...
0
votes
1answer
25 views

uint[] to address with correct checksum

Lets say we have something like this as a given: bytes20 b = bytes20(someAddress); uint8[] memory array = new uint8[](b.length); for (uint256 n = 0; n < b.length; n++) { array[n] = uint8(uint160(...
1
vote
1answer
19 views

Solidity: Saving arbitrary data into bytes array and later parsing it

I want to create a function that receives two addresses and saves them into a bytes array. later a matching function will receive this bytes array and parse the two addresses. function ...
1
vote
2answers
31 views

Who is msg.sender in a nested call chain?

I read about who is msg.sender when calling a contract from a contract, but who is msg.sender when calling a contract from a contract that calls another contract and so on and so forth?
0
votes
1answer
17 views

What are the parameters for the ideal gas limit?

I am new to writing smart contracts, in recent times I am having trouble in deploying the smart contracts couple of times so I need a solution for that. I am using the truffle most of the time so ...
0
votes
1answer
30 views

Event to alert when receive a token

I need to write a contract. That contract should detect and alert while receiving token/ether with some parameter. If somebody sends token/ether with some parameter to my contract. I need to know at ...
0
votes
0answers
17 views

address.call(abi.encodeWithSignature(“func(<param>)”, _params) doesnot work

contract C1 { uint public num; address public sender; function callSetNum(address c2, uint256 _num) public { (bool res,) = c2.call(abi.encodeWithSignature("setNum(uint256)",_num)); ...
0
votes
1answer
46 views

Why is my calculation broken?

I have a smart contract that holds a token balance, let's call it Token A, users may send this smart contract Token B to receive Token A, they do so by specifying the amount of Token A they would like ...
0
votes
1answer
30 views

How can I send an Anonymous event (In ABI, anonymous==true) in Solidity?

Here's my contract code, now in the ABI I have an anonymous entry and I'm not sure what is that and how can I emit anonymous event. pragma solidity ^0.4.24; contract TestContract { event Start(...
0
votes
1answer
59 views

TypeError: Wrong argument count for function call: 2 arguments given but expected 1. Use abi.encodePacked

I was playing with this post code example: function random() private view returns (uint8) { return uint8(uint256(keccak256(block.timestamp, block.difficulty))%251); } But I'm always ...
1
vote
2answers
39 views

Mapping not updating?

Here is the function in question : function WithdrawDividend(address, uint256 value) public { require(value <= _balances[msg.sender]); if (!RestrictedFromDividend[msg.sender]) { ...
2
votes
1answer
21 views

Is there a reason why minting is excluded in erc721 interface?

So the EIP-721 standard says, Creating of NFTs ("minting") and destruction NFTs ("burning") is not included in the specification. Your contract may implement these by other means. interface ...
0
votes
0answers
18 views

Why is my code calculating incorrectly?

My code to calculate the dividend someone is owed is as such : function ViewDividendOwed(address) public view returns (uint256) { if (!RestrictedFromDividend[msg.sender]) { return ...
1
vote
1answer
19 views

Why is the holder balance more than total supply? Why has nothing been sent to the contract?

My token is constructed with 100,000,000 supply. Each transaction, 0.007% is burned and a further 0.003% is sent to the contract, making it part of the dividend pool. Here is the transfer function : ...
1
vote
0answers
23 views

Pass hexadecimal literal to contract using web3js

I have a hex literal that I need to pass into a contract using web3, and I'm not sure how to go about formatting it. In solidity, its formatted like so: hex'...
0
votes
1answer
22 views

Adding the delta to a token transfer

Let's say I have 5 contributors to a pool of a smart contract. They all contributed 1 ether. The smart contract lost 2 ether, and now I want to transfer back the remaining 3 ether to the 5 ...
0
votes
2answers
43 views

Determine current stage in smart contract [closed]

Suppose that i have stages with date range and discount as follow. stage1 -> 2019-01-01 - 2019-02-02 -> 40% discount stage2 -> 2019-03-03 - 2019-04-04 -> 30% discount stage3 -> 2019-05-05 - 2019-06-...
0
votes
1answer
20 views

Expected identifier but got reserved keyword 'reference' Product public reference; ^-------^ [closed]

hello guys I am a beginner. I would like to make a function for create a contract. I found a example on the internet but gives me an error so I dont know what should I do. Anyone can help me ? ...
1
vote
1answer
31 views

How can I apply an effect to an address for a set time?

I am using a dividend pool system for my token. Currently, when a user withdraws their dividends they have this line of code is run: emit Transfer(address(this), msg.sender, DividendstoDividend); ...
0
votes
3answers
58 views

Error transferring balance. Runs out of gas

This is probably a simple problem to fix, but it is very frustrating. I am developing in Solidity using Remix 0.5.10. I have a loan contract that collects funds from borrowers. I now want to ...
1
vote
2answers
26 views

Error: gas required exceeds allowance or always failing transaction in Remix using Ropsten network

I am facing this error , My Contract is quite simple pragma solidity ^0.5.0; contract sendEther { address payable sender; function showReceiver() public view returns (address payable) { ...
2
votes
0answers
32 views

Nested usage of interfaces?

Using solidity ^4.x, it seems I can use an interface as a parameter type in a function from a different interface. Example: interface IERC20 { function transfer() external; } import "./IERC20....
0
votes
1answer
27 views

How to get ethereum gasPrice from a transaction hash?

I need to get the gasUsed and gasPrice so that I can calculate the correct amount of gas required for a transaction. I can get the gasUsed using: var accountOneReceipt = await contractInstance....
1
vote
1answer
51 views

Remix - another transaction execution failed

I am trying to reproduce the results on Remix with the smart-contract as written here: https://etherscan.io/address/0xb6ed7644c69416d67b522e20bc294a9a9b405b31#code (for remix, go to http://remix....
0
votes
1answer
28 views

The constructor should be payable if you send value. The transaction has been reverted to the initial state

I'm following a LinkedIn course on Solidity and creating a simple contract. Code below: I'm new to solidity so I'm not sure exactly where I'm going wrong but I get the following error: Transact to ...