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
0
votes
0answers
51 views
+50

Linked contracts not running on go-ethereum

A very simple linked contracts example where A contract has a variable and B contract queries the A contract's variable is running ok on Ropsten+myetherwallet and Remix sandbox, but it fails when ...
0
votes
1answer
22 views

Why does solc output bytecode that is not in valid hex format?

I compile my solidity file using the following command: solc Encoder.sol --bin --abi --optimize -o <output_dir>/ Then I try to deploy it in Geth: Encoder = eth.contract([<abi file content&...
1
vote
1answer
16 views

Gas COST for Contract Initialization

I am trying to understand the difference in gas cost between getTokenBalance for the two contracts below. In Example 1 ERC20 is initialized once during the deployment of SomeContract as a part of ...
0
votes
1answer
45 views

Help me Understand the flow of this smart contract

I have 2 smart contract, below is the implementatin of them : 1) import "./MaintainableUpgradeabilityProxy.sol"; function _createProxy(address implementation, address serviceRegistry) internal ...
0
votes
1answer
25 views

How to set different signer and gas payer for a single transaction

I am trying to make a transaction of DAI tokens from user wallet 0xDAIUserWallet to some random token contract say 0xRandomContractAddress. In this scenario I am using the private key of DAI User to ...
0
votes
0answers
30 views

Cannot call contract?

ive been trying for days to create a contract and simply call a function on it. Just to learn. But i can for the love of god not figure out what im doing wrong. I got truffle and Ganache set up, and i ...
0
votes
3answers
28 views

Solidity - Generate multiple, unpredictable random numbers that do not depend on input

I know that the "how to generate random number" in solidity is a very common question. However, after reading the great majority of answers I did not find one to fit my case. A short description of ...
0
votes
0answers
16 views

Remix forced error

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Internal JSON-RPC error. I got this error on my remix when I ...
0
votes
1answer
23 views

dApp design and security question

I'm designing a dApp where users can submit work they've done (files) to ipfs/swarm. To get credit for the work they then reference the hash of the files when calling a smart contract. What are some ...
0
votes
1answer
18 views

Ethereum Division

function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } When I call the function above as library in my solidity code 107752139522000.div(...
0
votes
0answers
11 views

How to find out in blockchain ledger the current ownership of asset being transacted

I am new to blockchain and smart contract as well. In smart contract we can only save the current state of any transaction but if we need to know the previously expunged transactional data ie, the ...
0
votes
1answer
29 views

Cannot deploy new contracts with pending transactions (Ropsten)

I have a very strange and annoying problem. I am trying to deploy a new contract however it just keeps cycling. I have the same problem on the POA testnet and on Ropsten. Please see below: I have ...
1
vote
1answer
25 views

Validating RSA, Ed25519 and ECDSA signatures in solidity

I am writing a contract in solidity for verifying multiple signature schemes.I found that solidity supports ECDSA, but how do I add check for RSA and Ed25519. is there any existing method/library ...
0
votes
0answers
26 views

Is it possible to see the execution cost of a function before it is executed?

I would like to assert the cost of an execution within a Solidity (5.x) function before executing it. To the best of my knowledge, this sounds like an incomputable problem, but I would like to check ...
0
votes
0answers
28 views

remix compiler just won't end compiling

I've just started my journy with etherium, so now I am trying to get my first script complied. I tried starting with this project https://github.com/san-lee-ai/simple_auction But I could not get the ...
1
vote
1answer
20 views

Invalid opcode when trying to pass address as parameter to contract

When I try to pass address as parameter to this addEmployee function it gives me this error: invalid opcode The execution might have thrown. Debug to get more information. modifier onlyOwner(...
0
votes
1answer
51 views

Unable to Verify Smart Contract

Currently I want to make a smart contract for verifying documents. However, I couldn't make it works. I have followed the tutorials as shown here (it is for Solidity 0.4.4 and mine is solidity 0.5.0) ...
0
votes
1answer
17 views

How to convert uppaal code to solidity code? [closed]

I wanna convert Uppaal code to Solidity code. The problem is that uppaal tool are not supporting some datatypes and function like uppaal is using "int" and solidity is use uint. We can't use string ...
0
votes
1answer
43 views

Node error when I deployed smart contract - Web3.js

I get this error when I deployed smart contract to my private chain. Error: Node error: {"code":-32000,"message":"unknown account"} This is my web3.js code. const bytecode = "...
0
votes
1answer
15 views

Direct and separate funds into two different payable functions

Basically I have this code where I'm trying to divide a specific amount of ether into two different function calls within the contract. function singleTransaction(arg1) payable { require(msg.value ...
0
votes
0answers
10 views

What is EVM15 as a Solidity output target?

In the Solidity compiler help menu solc --help, I noticed that evm15 is one of the new compilation targets in addition to evm and ewasm. I know what ewasm stands for, but what's the difference between ...
0
votes
2answers
24 views

How do we add values into the below struct ? Am a newbie here! Thanks in advance!

pragma solidity ^0.5.8; contract DriverRegister { enum CarType {mini, micro, prime} struct Driver { string name; uint phno; uint licenceno; bool ...
1
vote
0answers
39 views

Web3 - cannot deploy contract to private chain has been reverted [duplicate]

I want to deploy a contract to my private chain by using web3.js, but my contract deployment has been reverted by the EVM. This is error message index.js:1437 Error: Transaction has been reverted ...
0
votes
1answer
39 views

Sending entire contract balance to address

I am trying to establish a basic reversed auction in solidity using the Remix IDE. In the last function i want to pay back the whole contract balance to a certain address. My approach with .transfer(...
0
votes
1answer
29 views

Way to create an event?

As soon as a function is called this other function should also be called!! Example: As soon as ether is deposited it should transfer funds into employees wallet. I already have functions deposit() ...
0
votes
1answer
24 views

How to transfer ether to wallet addresses in an array?

address[] emp = [address1,address2]; amount = total/emp.length; for(uint256 i=0;i<employees.length;i++) { wallet = emp[i]; wallet.transfer(amount); } So This is the error I get. TypeError:...
1
vote
0answers
18 views

Error encoding arguments: SyntaxError: Unexpected Token A in JSON at position 3

I was able to successfully deploy my first smart contract. But I am getting the runtime error. I am trying to create a new product structure for each wallet and trying to initialize the structure. As ...
0
votes
0answers
22 views

How to build an ethereum based wallet with custom UI?

I have been interested in ethereum for quite some time now and have always wanted to learn ethereum development. I decided to create my custom erc20 tokens i was able to create 2,00,000 tokens. Now i ...
0
votes
0answers
32 views

Problem accessing variables stored in event log

I have succesfully implemented an event in my contract Portfolio: // Define eventlog for myEvent event myEvent(uint indexed eventDate, address indexed sender, myArray[] eventList, uint eventBalance); ...
0
votes
0answers
14 views

Calling a string from smart contract in go

all I want to do is call a string from a smart contract I've written using go. My smart contract is: pragma solidity ^0.4.24; contract String { string store = "abcdef"; function getStore() ...
1
vote
1answer
18 views

openzeppelin access roles.sol

I'm running this contract on remix https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/roles/WhitelistAdminRole.sol There was no error but i saw an warning "Gas ...
0
votes
1answer
24 views

Adding a payee to a donation contract. Error: Transaction reverted

Disclaimer: I'm a noob when it comes to programming altogether let alone smart contracts. I refactored this code that was written like three years ago so it could work with solidity 0.5.0. I deployed ...
0
votes
0answers
20 views

Truffle test including mainnet contract - Error: Cannot create instance of Whitelist; no code at address

Problem with the error Error: Cannot create instance of Whitelist; no code at address 0x6198149b79AFE8114dc07b46A01d94a6af304ED9 How do I have to setup truffle so that I can run a test which includes ...
0
votes
0answers
7 views

Puppeth usage in private PoA

I am about to setup a private network using Geth PoA (clique? still unsure as to what the purpose of this protocol is- clique not PoA); having rented 3 servers. My concern is should I be using puppeth ...
0
votes
2answers
29 views

how to write a test case for msg.sender==0?

In my contract I am use the below mapping. mapping(address => uint)Drivers In the function function registerDriver(uint _perkm) public payable returns(string memory) { require(...
0
votes
0answers
26 views

Metamask error: Transaction error. exception thrown in contract code

I've been successfully compiled and deployed my smart contract Campaign.sol. All the functions in my contract can run successfully but as I use my javascript file RequestRow.js to call my function ...
0
votes
2answers
35 views

Exchange ERC20 token with other ERC20 token

I have 2 ERC20 tokens. The contract are designed as standard ERC20. Here are the 2 tokens to take as an example - AUDC --> Contract Address: (0xContractAUDC) Wallet Address: (...
0
votes
1answer
31 views

Emited Solidity Events not being watched at frontend truffle contract instance

So, I have been reading through A LOT of pages about events in Solidity and how to interact with them on frontend but I am still pretty new to this and it seems like there have been multiple changes, ...
0
votes
1answer
31 views

What's the proper way to store a long string (like a news article) in Solidity?

I'm working on Layer 2 so gas/efficiency aren't primary concerns, assuming the function can be executed by the EVM
0
votes
2answers
28 views

How to disable a function from a parent contract?

Say I have this contract: contract Foo { uint256 public foo; function setFoo(uint256 _foo) public { foo = _foo; } function setFooToZero() public { foo = 0; } } ...
0
votes
1answer
45 views

Solidity returning a value to authorized address

I am writing a Smart Contract that saves a certain random hash given by the owner that is used for a 3rd party reason. I would like the owner of the contract to specify some Ethereum addresses that is ...
0
votes
1answer
11 views

Does packing bools alongside addresses reduce storage costs?

Say I have a struct like this: struct MyStruct { bool foo; uint256 bar; uint256 baz; address qux; } If I rewrite it like this: struct MyStruct { bool foo; address qux; ...
0
votes
1answer
22 views

Passing more than 20 parameters in solidity

How to pass more than 20 parameters in solidity function? I have tried using array[] parameter that uses pragma ABIENCODERV2 experimental feature. But this feature cannot be used in production purpose....
1
vote
1answer
19 views

When does it make sense to use `this.f()` instead of making the function public?

In external vs public best practices, Tjaden Hess says that: It almost never makes sense to use the this.f() pattern, as this requires a real CALL to be executed, which is expensive So why does ...
0
votes
1answer
20 views

Create2 and new contract deploy at used address

Given that it seems possible, using somehow CREATE2, to deploy a new smart contract at a certain address where a different smart contract existed before to be killed... (see @smarx answer here Can ...
0
votes
1answer
23 views

Can I put a lock on an already issued erc20 token?

Can I put a lock on an already issued erc20 token? I have issued a fixed erc20 and I want to know if it is possible to apply locku to smart contracts.
1
vote
1answer
22 views

Why OpenZepplin always use private visibility for state variables?

Why OpenZepplin always use private visibility with getter functions for its state variables? I can't find a reason why they are not using public, is there any potential security or gas cost difference ...
0
votes
0answers
31 views

Truffle how to test with reference to mainnet smart contract - Error: while migrating VM Exception while processing transaction: revert

I would like to run a truffle test on a smart contract that includes a smart contract address deployed on mainnet. However, this results in the following error Error: Error: Error: while migrating ...
0
votes
1answer
28 views

How to solve the error “”before all“ hook: prepare suite:” [closed]

When I tested my contract, I got this error ""before all" hook: prepare suite:" Does anyone know how to solve this error? This is my dependencies. "truffle": "5.0.7", "web3": "1.0.0-beta.46"
2
votes
2answers
37 views

Can you selfdestruct a contract more than once?

I read the Contract's state after a selfdestruct thread, but it doesn't answer the question whether you can selfdestruct multiple times.