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
0answers
18 views

Is there a RanDAO on Ethereum (Eth1)?

The only place I can find any mention of the RanDAO contract addresses is in this Reddit thread. Looking at them in etherscan shows that the last time they were used were used was ~1600 days ago, ...
1
vote
1answer
37 views

Best way to record document hash and address (mapping vs transaction input data)

First of all, sorry if the question is too open, is not a coding problem but a design decision. I'm doing a bit of research about storing a proof of a document existence (a hash of the document) in ...
1
vote
1answer
22 views

Way to fetch function name in fallback function with Solidity

I am writing a fallback function this way: fallback() external { (param1, param2) = abi.decode(msg.data[4:], (uint256, uint256)); } I know this is not a good practice but let's suppose i ...
2
votes
0answers
29 views

What are the front running bots?

I've been seeing too many threads about this. I was curious about what are they how do they function? Is it basically an automated trading algorithm that just executes trades when a cryptocurrency is ...
0
votes
0answers
48 views

Error: invalid arrayify value when deploying in remix [duplicate]

I got this strange error when deploying a contract in remix. Here is the constructor uint256 private value; bytes32 private itemName; //<<==cause error uint256 private itemId; constructor (...
0
votes
0answers
16 views

dapp without test.js

We can test our smart contract in remix and can perform several workflow checks before putting the contract in the final sol file in the dapp project. This way we can ensure that everything is in ...
0
votes
0answers
15 views

Transfer token from smart contract to 2 EOA addresses

There is an escrow smart contact which at the end needs to send the escrow balance back to both seller and buyer. Here is the contract (without all the details) pragme ^0.7.0; interface ERC20Token {.....
1
vote
1answer
24 views

What does scope do in the function itself?

Here is one of the functions I am curious about... function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, '...
0
votes
1answer
18 views

Truffle Test AssertionError: error message must contain revert

I can't figure out why this error occurs Here my test js code: var YarockToken = artifacts.require("./YarockToken.sol"); contract('YarockToken', function(accounts) { var tokenInstance; ...
1
vote
2answers
29 views

what's the difference between call and just using function?

Let's say I have a contract called contractA. It has the function: function bla(address test) { // way 1. test.call(abi.encodeWithSignature("first4bytes", arg1, arg2)) // way 2. ...
0
votes
1answer
23 views

Schedule a transaction without making a deposit

Is it possible in solidity to schedule a transaction without making a deposit and without specifying the amount? As far as I know with the Ethereum Alarm Clock you need to deposit the ethereum and the ...
1
vote
2answers
19 views

Solidity: returning parameter

I'm a bit new to the Solidity-thing and am asking myself the question what to do with functions that specify a certain (set of) return parameter(s) and then fail to compute/find the desired return ...
0
votes
0answers
11 views

About security problem on hard fork named “Spurious Dragon”

What is the specific problem with the secuirty of "Spurious Dragon" (EIP-170)? I've heard that EXTCODESIZE isn't checked when accessing the constructor and doesn't cost a gas fee, but I'm ...
0
votes
1answer
26 views

Fail to transafer Ether to child contract from parent contract

I created a contract factory (parent contract) for creating a child contract. In the parent contract, there is a function to transfer the balance of the parent contract to the child contract, by ...
0
votes
1answer
13 views

Where can I find the specific contract implementation for the part __unstable__ERC20Owned?

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/90ed1af972299070f51bf4665a85da56ac4d355e/contracts/GSN/GSNRecipientERC20Fee.sol Where can I find the specific contract implementation for ...
1
vote
1answer
23 views

How can I transfer ERC20 Tokens to Bitcoin donor in ICO?

I developed ICO on solidity. As everyone knows smart contracts only accept ETH, but I've seen many ICOs which accept BTC and any other cryptocurrency as well. I want to know how can I handle it if ...
0
votes
0answers
11 views

Getting this error when I run a test on truffle : sets the total supply upon deployment

When I try to run a test from truffle, I got this problem, here my test js code: var YarockToken=artifacts.require("./YarockToken.sol"); contract('YarockToken',function(accounts){ var ...
0
votes
1answer
20 views

How to hide the private information of the transaction sender?

I want to implement the following functions in theory through solidity in test chain environment, and it is not required to be implemented in a production environment: a user can initiate a ...
2
votes
2answers
35 views

Who is the msg.sender when calling function of ERC20 token contract inside a smart contract?

Here is a function in a smart contract to call transferFrom in ERC20 token contract. pragma ^0.7.0 interface ERC20Token { function transfer(address recipient, uint256 amount) external returns (...
2
votes
2answers
34 views

What is in return when listening to an event?

In Hellos.sol, there is event initContract after constructor is called. Here is the solidity code: pragma solidity 0.7.0; contract Hello { address owner; uint256 value; event ...
0
votes
1answer
23 views

Storing multiple values in one key mapping dynamically

I am making a blockchain project using solidity which requires storing various objectIDs corresponding to a personId. The person can add and remove objects and we cannot hard-code the number of ...
1
vote
0answers
25 views

capture an event issued by a smart contract and make a web request [closed]

I am making a project using Ethereum and web3js. In this project , I have contract A and contract B (oracle smart contract). When A calls a function of B, B emits an event. An oracle service captures ...
1
vote
1answer
19 views

the difference in the meaning of each way that generally works as a way of calling other functions

I get an error in the code below. function test2(address _t) public { // Owned no deploy address => owned() if (!_t.call.value(msg.value)(bytes4(keccak256("test()")))){ ...
1
vote
1answer
33 views

What is the use case of transferFrom function in ERC20 token contract?

In @openZeppelin's ERC20 implementation here is the code for function transferFrom: function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { ...
0
votes
1answer
15 views

Using openzeppelin Interfaces

If I import an openzeppelin Interface using @openzeppelin/contracts/token/ERC721/IERC721.sol, do I still need to declare the functions I wish to use found in the Interface, or the import statement is ...
0
votes
1answer
35 views

Solidity Contract Invalid Opcode RPC Errors

I have a pretty straight-forward contract that let's you buy ERC721 Tokens. My issue is that my "buyToken" function works half the time - and fails the other half of the time with the ...
1
vote
1answer
63 views

Chainlink: Data in JSON object not returning

I am using Chainlink to get a value from an API for my smart-contract. I just want to do a simple Get request as described in Chainlink's documentation. Here is the scripte taken from the ...
0
votes
0answers
32 views

web3 - Uncaught TypeError: Cannot read property 'methods' of undefined

I am made a coin flip dapp and am using ganache to deploy it. A player has to selects a number between 0 and 1. I read this error means "the contract is undefined" but I do not know how to ...
0
votes
1answer
49 views

How to send ERC20 token to smart contract in constructor

When deploying a smart contract to a private network, how to send ERC20 token (on the same private network) in msg.value to the smart contract in constructor? Here is the contract: pragma ^0.7.0; ...
1
vote
1answer
33 views

using only html page for frontend with web3 or ethers.js

I was just wondering, since we are able to write js scripts inside html docs, would we be able to create a dapp with fully functional html front end for our smart contracts? Or would we need to use ...
1
vote
0answers
14 views

Replacing pending deploy tx with truffle

I deployed my contract with default params using truffle migrate --network mainnet --reset the gas was too low and got my tx pending for more than 20 hours already. I wanted to replace the tx with new ...
0
votes
1answer
37 views

How to encode arrays for solidity function calls

I want to understand how to encode the following arrays in Solidity. Dynamic Arrays For example, the following: function getDynamicUintArray() public pure returns (uint[] memory) { uint[] ...
0
votes
0answers
16 views

How to catch a solidity event from Java

I am trying to make a decentralized android application. It is an online two player Tic-Tac-Toe game. I have implemented the back-end with solidity and a part of the front-end in android studio. ...
1
vote
1answer
25 views

Do file names need to be UTF-8 for solc to be able to compile them?

I combed through the Using the compiler section in the Solidity documentation, but I couldn't find an answer for my question. Do file names need to be valid UTF-8 for solc to be able to compile them?
0
votes
0answers
19 views

Create an sale contract with ERC20

I want to test a sale contract, that also takes ERC20 tokens and mint/burn another IERC20 token. In this excample I try to implement USDT: pragma solidity >=0.5.0 <0.8.0; import "@...
2
votes
1answer
94 views

what stops devs from changing supply of contracts?

If someone created an erc20 token with the state variable uint256 totalSupply = 100, what is stopping another dev from creating a contract with that manipulates the totalSupply to 0? Would making the ...
1
vote
1answer
63 views

Provider does not have a request or send method to use

I am doing the Ethereum and Solidity: The Complete Developer's Guide and I am unable to resolve this error. The code is expected to do a transaction via await factory.methods .createCampaign(this....
0
votes
1answer
37 views

Problem while compiling a solidity contract with truffle

Each time that I compile a contract with truffle I get this error: (cmd) # Compiling your contracts... > Compiling .\contracts\HW.sol Error executing vyper: 'vyper' is not recognized as an internal ...
0
votes
0answers
18 views

How to solve Transaction has been reverted by the EVM , In need of a solution based on my code?

I have been using ropsten with infura. SMART CONTRACT contract Don { struct Details { uint id; string name; string dob; ...
0
votes
0answers
28 views

moving funds from contract that owns all total supply

So I've given the total supply to this contract via making an address state variable address creditsContract = address(this), and was wondering if I could call the transfer function from another ...
0
votes
1answer
18 views

How to read the return object of call to function in a contract?

Here is the function isDude in a contract. If the address is recorded, then isDude returns true. Otherwise it returns false. Here is the contract function isDude: function isDude(address _dude_address)...
0
votes
1answer
36 views

How to get an interface form smart contract

I have a Smart Contract that I deployed on the blockchain. I would like to create another smart contract that will call the first smart contract. I would like to create an interface containing method ...
2
votes
2answers
55 views

Pegging a contracts 'price' to USD?

I have a contract / dapp that is "pay to play". You send X amount of Eth, and you can play. I have a price feed working via Chainlink, but I'd like to peg the Eth amount to USD. Where the ...
0
votes
1answer
24 views

How can I make an asynchronous interaction between two contracts?

How can I make an asynchronous interaction between two contracts? I have contract A and contract B. contract A calls contract B contract B obtains data from an external source contract B returns the ...
0
votes
0answers
24 views

Predict a contract's deployment address [duplicate]

I have read it was possible to predict the address of a contract before deploying it. Do you know how can this be possible ? What happens if we send some Ether to this address before deploying the ...
0
votes
0answers
12 views

Why do i need overide keyword when implementing an interface

Look at this interface: interface Contract1Interface { function myfunction(uint) external returns (uint); } I have implemented a smartcontract from this interface: contract Contract1 is ...
0
votes
0answers
13 views

Solidity functions visibility modifiers

I have read several documentations and tutorials about solidity. There is something which is not very clear for me: Let's take a basic example: contract MyContract1 { function public_function(uint ...
1
vote
1answer
23 views

Publish a File and Other Values

Background I'm working on this app that allows users to upload PDF files to IPFS. A Document consists of the title, address (the uploader), price, description, and the file itself. I've looked at ...
0
votes
0answers
14 views

Error at calling the memory function

I am using an remix ide for the smart contract development, at the time of compilation of the below code I am facing the error of expected primary expression. Could anyone help me out with this ...
0
votes
0answers
13 views

try catch syntax in solidity [duplicate]

I have read that "try catch" structure in solidity is dedicated to external calls. Are there other reasons we should work with "try catch" structure ? Here is what i've tried in a ...