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
1
vote
2answers
15 views

How to check if an address is an active contract in Vyper?

Often for security reasons I want to limit certain address parameters to non-contract addresses for certain functions in my contracts, ie. there are no code stored on the addresses passed in as ...
0
votes
1answer
44 views

How to do RSA signature verification based on eip-198

based on EIP-198 and a question asked here After EIP 198 introduction, how much gas is required for RSA signature verification in solidity? it should now be possible to do RSA signature verification ...
0
votes
1answer
22 views

Parser Error On Remix Solidity ERC20 Smart Contract Token

This Is My First ERC20 Smart Contract Token. I Am Trying To Compile It Using Solidity 0.5.0. Plz Need Your Help Guys. pragma solidity ^0.5.0; contract TusharCoin { uint256 public totalSupply; ...
2
votes
1answer
24 views

How are we able to send 512 bit hash as a bytes32 variable?

I have a code that is working: solidity function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) { bytes memory prefix = "\x19Ethereum Signed ...
0
votes
1answer
27 views

How can I store multiple strings mapped to an address in Smart Contract (solidity)?

I want to save multiple files in Ipfs and store its hashes mapped to an user address. I thought of having an array mapped to address and pushing to it, but does not seem to be the right approach. ...
1
vote
2answers
32 views

Decentralized Time server to get time in Dapps? [closed]

So basically i want to ask that how can we programmatically get the accurate, exact and current time in a DApp, without relying on the system's time or a centralized time server ? Is there a ...
0
votes
1answer
16 views

Solidity event not showing up from Web3.js

I'm trying to set up an event in Solidity and listen to it from Web3 but I keep getting a null response. Here's my code: The relevant part of the contract: event NewUser(string userid); function ...
4
votes
1answer
32 views

Can a Smart Contract receive and send E-Mails?

As the title states, I would like to know whether one could create a smart contract on Ethereum that is able to send and receive E-Mails.
0
votes
0answers
24 views

How to achieve inheritance support using web3j wrapper?

I have two types of smart contracts. One parent contract to store the type and other child contracts which inherits the parent contract. The problem is, I can't generate java wrapper class (...
0
votes
0answers
27 views

Solidity Contract cost calcuation

How can I calculate the cost of running my contract and running each function? I've noticed in Ethereum when a transaction is successful we have a transaction cost and a execution cost, what the ...
1
vote
1answer
21 views

How do mappings in solidity occupy memory

Say, I declare a mapping that uses uint256 numbers as keys and maps them to a single 8 bit character. I add 5 members to this mapping. Obviously, I can then access any of these 5 characters using ...
0
votes
0answers
8 views

DigixDAO smart contract functionality/pattern

Can someone explain the usage of initialisation functionality and _resolver arguments in the various constructors of digixdao? i.e. following contract What is a resolver and isn't the job of a ...
0
votes
1answer
32 views

Solidity group addresses with a name. Eg: Whats app groups

I want to create a squad(group) which consists of a group addresses. Like Squad XYZ consists of Addr1 with name 'A',Addr2 with Name 'B', Addr3 with name 'C'. pragma solidity ^0.5.9; contract Squads{ ...
1
vote
1answer
22 views

How to get timestamp of an event log in emitted event from smart contract

I want to get the timestamp of an event. How can I get time of event fired, if the event data does not contain any time value?
0
votes
1answer
21 views

Getting information from contract address?

pragma solidity ^0.5.0; import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol'; contract SubToken{ using SafeMath for uint; struct token{ ...
1
vote
1answer
28 views

How to initialize inherited contract

I find there is a contract named ERC20Capped inherited from ERC20Mintable in zippelin contract project. Both of them have their own construction parameters.How to assign value to them during contract ...
0
votes
1answer
12 views

interface function declarations to be used internally

Is it possible to use externally declared interface functions internally in a smart contract? i.e. say contract A inherits interface A, would contract A be able to implement the functions from ...
0
votes
0answers
30 views

Is it possible to insert some custom data in the DATA field of an Ethereum Transaction?

i am working on trying to get some data encoded/inserted into an ethereum transaction. Let me describe my environment first, i am using Web3py, Ganache and Remix IDE. I am able to successfully ...
-3
votes
2answers
39 views

Trying to create an instance of an abstract contract

pragma solidity ^0.5.0; import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol'; contract SubToken{ mapping(address => uint) balances; ...
0
votes
1answer
23 views

Inheritance and contract creation

If I modularise a contract into two contracts, and inherit one of them instead using a monolithic approach, will the deployment costs be larger with two contracts or is the cost the same as with the ...
0
votes
0answers
11 views

Contract Design Patterns | Should I use some sort of factory pattern?

I have 3 structs which are nested into each other i.e. struct A <- struct B <-- struct C All 3 structs belong to their own contracts (contract A, contract B, contract C) and each contract has ...
0
votes
0answers
9 views

when to create a library contract

when should one consider creating library instead of a contract? Would it make sense to create a library if all it does is calculations or reporting read values?
2
votes
1answer
14 views

Solidity: How to replace specific string position with letter?

I would like to replace a letter at a specific position of a string with another letter. function _stringReplace(string memory _string, uint256 _pos, string memory _letter) internal pure returns (...
0
votes
1answer
25 views

Solidity Events

I'm using Solidity events to interact with my html page, once a change is done in the contract or page the watch function from html reflects back to the contract. My question here is, while checking ...
-2
votes
0answers
33 views

ownership and gas

I have just started implementing ownership checks in my code. I used the code: contract owned { constructor() public { owner = msg.sender; } address public owner; } Then ...
0
votes
1answer
17 views

State variable ERC721Token

contract Test { ERC721Token public tokenAddress; constructor(address _address) public { tokenAddress = ERC721Token(_address); } } In this example, I just tested tokenAddress returns the ...
0
votes
0answers
32 views

Saving a function in a variable in Solidity

I am very new to solidity and stack exchange as well. I am trying to use the date time api from https://github.com/pipermerriam/ethereum-datetime/tree/master/contracts. What getYear(date) does is ...
0
votes
0answers
13 views

Best Practices Of Building A DAO Contract Structure Tree

When building a DAO of interconnected smart contracts on Ethereum, what is the best way to organise the contract structure? More specifically, are there any particular design pattern(s) like MVC in ...
0
votes
1answer
26 views

Why string variable must be memory from solidity v5.0?

May someone explain me why exactly string variable must be memory from solidity v5.0 and what does tha mean? Thanks for your help.
2
votes
0answers
22 views

How Can You Map a Struct Twice With Different Keys?

I have a struct mapped with an address as the key. I want to iterate through all values of that mapping with another key value, in this case a nonce that I generate in the contract. Is this possible? ...
3
votes
1answer
45 views

Issue in ERC721 token transfer to contract address

I am using ERC721 implementation for NFT tokens. I am testing the transfer functionalities in ERC721. `transferFrom(address _from, address _to, uint256 _tokenId)` `safeTransferFrom(address ...
0
votes
1answer
18 views

most derrived override

According to solidity docs, pragma solidity ^0.4.0; contract owned { function owned() public { owner = msg.sender; } address owner; } contract mortal is owned { function kill() public { ...
0
votes
1answer
34 views

Why Web3 event callback fires multiple times same as the number of the solidity smart contract emitted that event in past?

I am just learning, solidity with react and web3 and I am facing the issue on page load the callback event of web3 called multiple time the number is same as I called a solidity function and that emit ...
2
votes
2answers
23 views

Is there a way to be notified when ERC721 is deposited?

We are coding a contract that will work with ERC721 tokens, basically a Plasma Root Chain contract. We need this contract to do some work whenever it receives a new ERC721 token from a ...
3
votes
1answer
29 views

approve-transferfrom pattern between contracts

What is the general process-flow of approving contract a to spend tokens on behalf of contract b and how would a sufficient function implementation look like which successfully achieves this? For ...
0
votes
0answers
20 views

Generated code using web3j contains errors

this is the smart contract ''' pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; import "./sharedLib.sol"; import "./clientSC.sol"; import "./projetSC.sol"; contract CrowdFactory{ uint ...
3
votes
2answers
50 views

Setting Remix default Compiler Version

Is it possible to set the default Compiler version in Remix? Each time I open Remix, the compiler defaults to version 0.5.0+commit.1d4f565a. However, there is currently up to version 0.5.10 available ...
4
votes
1answer
25 views

Invalid implicit conversion from bytes calldata to bytes storage pointer requested

The code below produces an error: code: function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes calldata _data ) external { _safeTransferFrom(...
0
votes
1answer
28 views

What is (fallback) method in a contract?

I'm new to Solidity programming and I don't know what is (fallback) function generated when I deploy a DAO contract. It is not defined in the contract code. Sample code I used: pragma solidity ^0.4....
2
votes
1answer
20 views

How does one retrieve revert/require error messages from RPC

In both of these questions, the user is asking if it's possible to get the error string from a revert or require. The answers say, basically, "Yes" and point to Truffle or other methods. VM Exception ...
1
vote
1answer
40 views

Delegatecall return values solidity 5.0

With solidity 5.0+ , the delegatecall function can return a boolean and a bytes representing return value. I want to understand how does one convert the returned bytes to various datatypes. ex If ...
2
votes
2answers
57 views

How to guarantee IPFS file access based on Non Fungible Token ownership (or security)?

The file is too big to be stored on the blockchain, so it is stored on IPFS. Only the person who owns a unique Non Fungible Token (or a Security Token) can access it. Of course I can encrypt the file ...
0
votes
1answer
28 views

Sending value to a solidity contract method from web3 results in `Invalid Tuple Value` error

I'm sending values to a solidity 0.5.1 method using web3 and keep getting an invalid Tuple value error. Here's the relevant contract code: struct mystruct { bytes32 id; string str; } ...
1
vote
0answers
127 views

Solidity and Web3js codes are not working inside the private Ethereum(geth) network but same codes are working in public ethereum

geth version : 1.9.0-stable-52f24617, node version : v10.16.3, npm version : 6.9.0, web3 version : -- web3@1.0.0-beta.36. genesis.json: { "config": { "chainId": 9663080, "homesteadBlock": 0, "...
0
votes
3answers
63 views

How to generate the full list of function selectors for a contract?

A contract has many functions and how to automatically generate the full selector list, including inherited functions, for the whole contract? Preferred solution shouldn’t require more than a web ...
2
votes
0answers
18 views

Increasing the difficulty/cost of manipulating an on-chain PRNG?

well, from what I understand since everything on-chain is deterministic so theoretically there's no way of having a real cryptograhically secure random number generator that cannot be manipulated by ...
0
votes
1answer
35 views

Web3 0.20 contract deployment

environment: Web3 0.20.7,Infura,node.js(backend) Deploy contract with Web3 0.20.7 pragma solidity ^0.5.1; contract Bang{ address holder; address proxy; constructor (address _holder, ...
0
votes
0answers
20 views

Interface restrictions

Why are interfaces restricted to enums, events, structs and functions? Why are they restricted from containing state variable declarations if they can contain structs?
0
votes
0answers
12 views

when to use byte32 -> string conversion in events, functions etc

When is it a good practice to use string conversion from bytes32? i.e. in events, functions and similar. What does doing so bring in terms of cons to gas costs?
2
votes
0answers
16 views

Name Styling Best Practices Internal/External variables/functions etc

The solidity docs clearly specify how to style function order, types etc. However, are there an appropriate way to also separate between internal/external variables, functions etc. I see some people ...