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
1answer
22 views

How can I encrypt a file using an ethereum public address and decrypt it with the private address?

The expected outcome is very simple: Users will send their ERC20s to a smart contract. Depending on the amount, each user will get a file specifically created for them. I want to distribute that ...
0
votes
1answer
14 views

Problem Declaring Array of Structure

I am trying to declare array of structure but its not accepting. I got this program from internet. pragma solidity ^0.5.1; contract NaiveBank { struct Account { ...
0
votes
1answer
22 views

How do I deposit an Ether amount to the smart contract function, namely deposit ? (Metamask version 0.20.7)

I have a problem with using the deposit () function on a smart contract. How do you use metamask 0.20.7 ? const contractInstance = web3.eth.contract(contractAbi).at(contractAddress); contractInstance....
0
votes
2answers
24 views

How do I get the return uint value of a method in Solidity contract from another contract

Trying to get the return function of a contract from another contract. Don't know what I am doing wrong. I can see the return value when I call contract A directly but when I try calling the function ...
2
votes
1answer
34 views

How to avoid an error caused by wrong determining of gas consumption

I have a function that is being called by multiple users (say 3). That value is set by owner earlier as a constant. Inside this function there's a check whether it's the last user (3) or not. If yes ...
0
votes
1answer
28 views

Solidity - preventing negative uint parameters/overflow

Since web3 apparently doesn't require functions with uint parameters to have positive values for those parameters, I thought I'd try it in Solidity. I'm posting this to see if I'm overthinking it, if ...
1
vote
1answer
24 views

How can I create Ethereum wallet addresses that can be revoked after certain time? Is it possible to do that?

How can I create Ethereum wallet addresses that can be revoked after certain time? Is it possible to do that? I am trying to create temporary wallets for employees in a company for their company ...
0
votes
1answer
26 views

Are there any good ways to express conditional ownership on ERC20 or ERC721 tokens?

I'm currently looking for any good ways to express conditional ownership on tokens. I look into approve function of both ERC20/ERC721 but, it seems that function may be disapproved by the owner and ...
0
votes
1answer
17 views

Can I call someone else's public function/contract

Still new and learning. Forgive me if this is a stupid question. Since all contracts are uploaded to the same blockchain, if I wanted, could I use someone else's public contract in my own front-end ...
0
votes
2answers
32 views

Uninitialized storage pointer error

In solidity version 0.5.8, it is giving me the error that I have an uninitialized storage pointer. How do I fix this error, and if your answer is by making it a memory variable instead of storage ...
1
vote
2answers
47 views

How to test a custom fallback function using web3.js?

I am trying to implement a proxy pattern. I have a proxy contract and a lottery contract, and I would like the proxy contract to delegate calls to the lottery contract. To test that the function ...
2
votes
1answer
28 views

How to transfer wei from a contract to a specific address?

I was making an auction system and I wanted to make sure that when someone bid higher the contract would return the money to the address of the previous bid. pragma solidity >=0.4.22 <0.6.0; ...
1
vote
0answers
16 views

lvalue expected when modifying an object

Why does modifying an object's property cause an lvalue error when those only apply to arrays/mappings? contract Parent { mapping (address=>Child) public childObjects; function modify(address ...
0
votes
1answer
22 views

Two smart contracts interact can't pass value when I using web3.js

I have two different smart contracts interaction_1 and interaction_2 I input the data(team) from remix ide. What I want to accomplish is when user input team in user_input function at interaction_1,...
0
votes
1answer
22 views

Connecting to Rinkeby using Infura and calling a state-changing function from smart contract

So i have trouble using a smart contract on Rinkeby through infura as it gives an "extra-data" error, which as far as i have read, is due to Rinkeby being a POA testnet. There are suggestions of using ...
0
votes
0answers
37 views

How to print the value of a Struct ?(mapping)

If the set function receives two inputs 1.["0xca35b7d915458ef540ade6068dfe2f44e8fa733c",50,"ROC","park"] 2.["0x14723a09acff6d2a60dcdf7aa4aff308fddc160c",60,"AU","school"] How do I display the ...
0
votes
0answers
27 views

not able to assign address to a public property using web3

while everything is working fine when working on remix ide but on truffle its not updaing value of a property (player2) i am also returning that address value and its returning as it should be. but ...
0
votes
1answer
34 views

How to transfer ERC20 tokens from an account to a contract?

I'm struggling to transfer my ERC20 token toward a contract address. My code is like this. What's wrong with my code? the code is like this. Contract A{ function deposit(uint amount) public { ...
0
votes
1answer
35 views

library modifying string vs string literal

I have a library which has the following function: function strConcat( string memory _a, string memory _b ) internal pure returns (string memory) My contract implements the library ...
0
votes
1answer
17 views

How do you get casted uint division to work like literal division?

How do I get testDivCast() to return the same result as testDivLiteral()? pragma solidity ^0.5.1; function testDivLiteral() external pure returns (uint16) { return (1 / 5) * 100; } // ...
0
votes
0answers
37 views

Can not tranfer eth with solidity and web3js

Error when I try to send eth from fontend react to smart contract and from contract I tranfer eth to another address but it error, when I try it in remix then it total work. I user web3js to call ...
0
votes
0answers
19 views

Error based on inheritance and dependency between contracts (Using EternalStorage contract)

I have been using EternalStorage contract with my contracts for the storage purpose. Now the structure is some like this: Eternal Storage <- Contract (A) <- Contract (B) <- Contract (C) Now ...
0
votes
2answers
21 views

Should I include all public and view functions under contract ERC20Interface?

Should I include all public and view functions under contract ERC20Interface, why or why not ?
0
votes
1answer
23 views

Difference between a.add(b) and a+=b as well as a=a+b?

For example, if I have: balances[from] -= tokens; balances[from] = balances[from]-tokens; balances[from] = balances[from].sub(tokens); What is a difference and why should I use one rather than the ...
1
vote
2answers
35 views

I Call SmartContract Token ERC20, Why Show Hashing Output ? (Web3 + Metamask + Javascript)

I do not know why with this, even though in the previous version (web3 + Metamask) can issue real data. But now used as hashing (output). I took the example in the code and output below (to get the ...
0
votes
1answer
52 views

Contract Fallback function with ERC20

I see the fallback function of a contract as a way of "depositing" an Ether value to the contract. My question is very simple I guess, but I couldn't find the answer yet. Is it possible to develop a ...
0
votes
1answer
71 views

How to loop an array and store values in another after if conditions

I am trying to do something that I believe it should be simple enough. I want to make a getter function iterating a struct array find the min value and the values that is equal to this minvalue of a ...
0
votes
1answer
27 views

Combine BytesX and BytesY to create BytesZ?

I am working on a Solidity Smart Contract (^0.5.10) where I want to return an array of Ratings elements. struct Ratings { address restaurant uint8 score }; Since returning Rating[], string[]...
1
vote
1answer
25 views

How to call a function with params and check them

I want to create a smart contract that users can send a number to and receive an amount of ether. function airdrop(uint val) public payable { require(airdrop == true); if (val == 0x31){ ...
0
votes
0answers
27 views

web3.utils.toHex but combined, hex concat?

I'm currently working with bytes in Remix. The goal I wanted to achieve was to put variables into bytes in one function, copy bytes, paste bytes to another function as a parameter and unpack these ...
1
vote
1answer
34 views

Possible to get enum length / count in solidity contract?

Is it possible to access the length of an enum in solidity? E.g. pragma solidity >=0.4.16 <0.6.0; contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } function ...
0
votes
0answers
29 views

web3 - Can I call a library function without a contract?

I have a library which contains a function concat - it can merge two bytes. I have deployed a contract which uses that library and it works. I would like to make a simple bytes builder on my website. ...
4
votes
2answers
53 views

Verifying a Token Contract with Interface

I managed to deploy a token contract with interface on Kovan Testnet. Now I wanted to verify the code. However this is a bigger problem than I thought. The contract got successfully deployed to: ...
5
votes
1answer
64 views

When should I use calldata and when should I use memory?

I have seen people use both memory and calldata keywords when writing Solidity. Specifically, they are used when declaring function parameters. When should I use memory and when should I use calldata?...
0
votes
2answers
42 views

Am I Generating Random Numbers In A Non-Mallable Fashion?

Would this be a non-malleable way to generate numbers for my particular use case? Let me explain: I allow people to register for a lottery-type event. If a winning seed belongs to their ticket set, ...
0
votes
1answer
29 views

Setting methods permissions a quorum network

I have 3 solidity smart contracts that run in a quorum network with 7 nodes. At the moment i use the constructor to set the owner of the smart contract, that is the node that deployed it. ...
0
votes
3answers
77 views

How do I make a smart contract send a message to a user along with a transaction?

Smart contracts can obviously send transactions through the Ethereum network but can they also send a simple message along with the transaction? Usaully you would put the message into hex code in the ...
2
votes
2answers
58 views

Drizzle and Contract Instances

I am currently developing a dApp with Drizzle on top of ReactJS. My project consists of, basically, 8 .sol files. 4 of them are just abstract contracts that include the functions, structs etc. for ...
1
vote
1answer
20 views

Are there identifiers for smart contracts?

Say I want to reference another smart contract in my smart contract. Do smart contracts have an identifier (like a number 0xjdjdjdjdjjddj etc.)? And if they don't, how would you reference a ...
0
votes
2answers
36 views

truffle migrate fails silently

I'm trying to deploy a truffle project to testnet. When I run truffle migrate --reset --network rinkeby --verbose-rpc, this is output: You can improve web3's peformance when running Node.js versions ...
1
vote
2answers
33 views

How to convert string to bytes256 or arbitrary bytes?

I already know how to convert bytes32ToString and stringToBytes32: function bytes32ToString(bytes32 x) public pure returns (string memory) { bytes memory ...
4
votes
1answer
45 views

couldnt understand implementaion of UpgradeabilityProxyFactory

I want to use UpgradeabilityProxy provided by zeppelin, they have one method createProxyAndCall which they say initialize the new implementation with data parameter we provided which looks like: * ...
1
vote
1answer
17 views

Is it possible to process tranactions only after a certain number of calls are made (without a significant increase in the gas price)?

I would like to process N number of transactions in batches. When N people make a call to a transfer function, I would like to process all N transfers (and not before that last call is made). Then,...
0
votes
0answers
11 views

Random Number Generation, Appropriate case or no? [duplicate]

I'm building a lottery where I need to generate a list of random numbers. Basically, I have a group of people who will commit to a prize by staking a certain amount of tokens to their commitment - ...
0
votes
1answer
40 views

Smart contract copy

So I am in a permissioned blockchain setup, using Quorum as a client. I have deployed a private smart contract to members A and B, and now I have the need to redeploy it, giving access to member C. ...
0
votes
1answer
65 views

Ethereum gas limit using Geth

I am running a private blockchain using Geth, after upgrading the servers- I had stopped the miner and restarted it after upgrading the specs. Now I am getting all sorts of errors, the main one being ...
0
votes
0answers
10 views

TypeError: Function overload clash during conversion to external types for arguments

Why do I get following error "TypeError: Function overload clash during conversion to external types for arguments." when using compiler version ^0.5.0; but when I choose 0.5.2; and later releases ...
0
votes
0answers
31 views

gas required exceeds allowance (42000000) or always failing transaction

Below is my solidity code. When i try to run function insertBusinessHash, the error "gas required exceeds allowance (42000000) or always failing transaction" pops up. Any suggestions? pragma solidity ...
0
votes
1answer
37 views

Can't transfer ether from contract to another contract ^0.5.0

I try to transfer ether from one contract B to contract A. But I get "Transaction mined but execution failed" Code: pragma solidity ^0.5.0; contract A { address payable public owner; uint ...
1
vote
0answers
36 views

UnimplementedFeatureError: Variable inaccessible, too deep inside stack (17)

I'm getting this error, with no indication of which line of code or variable is responsible. I know it goes away when I comment out pragma experimental ABIEncoderV2; …but I need ABIEncoderV2 as I ...