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
5 views

Payable and address.transfer for ERC20 token

I am trying to develop forsage like MLM using ethereum smart contract. But I like to use ERC20 token for registration payment and dividends. The ERC20 token is already deployed. I have to use deployed ...
-2
votes
0answers
15 views

BITCOIN WALLET TO INTERACT WITH ETHEREUM SMARTCONTRACT [closed]

After I built an escrow smart contract with solidity how do I use Ethereum, Bitcoin, and LTC wallet, USDC to interact with it? cause I feel they are all blockchain. I will appreciate ideas and a ...
2
votes
1answer
13 views

Difference in cost between external contract as state variable vs. instantiation of contract?

For pragma solidity ^0.6.0; interface ExternalContract { function initialize() external; } contract Test { ExternalContract c; constructor(address externalContractAddress) public { ...
0
votes
0answers
15 views

join an array of strings and map, filter, reduce functions in solidity

I want to concatenate an array of strings into a single string using solidity, just like the array join function in javascript and python. Also I want to do map/filter/reduce functions in an array. Is ...
0
votes
1answer
14 views

Sending ether to my smart contract: function payable keyword or fallback function,

Between the two options to send ether to my smart contract, which is best to use or are they same
0
votes
1answer
14 views

Converting bytes32 to uint256 in solidity

How to go about converting a bytes32 variable to an uint256 variable in solidity? A straight forward conversion is not possible since when I converted the bytes32 variable which has a value of 99 to ...
0
votes
0answers
41 views

How can i remake this on keccak256 hash in nodejs

In my contract i'm verifying some data if it was correctly signed by the owner. It looks like this: require( owner() == ecrecover(keccak256(abi.encodePacked(this, aCustomId)), v, r, s), ...
0
votes
1answer
24 views

What are the meanings of `(uint256) (a)` and `(int256) (a)` in Solidity

I came across the following code payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); What is meaning of (int256) in this line, and is there any possibility of overflow here? Or here: ...
0
votes
0answers
15 views

public view function returns the correct answer for all but one variable, which it wrongly returns 0 everytime

I am using web3.js, and have tried calling the same contract on ropsten and kovan. I tried it on Infura and then Alchemy apis. Everytime, it simply returns 0 for one essential variable, when remix ...
1
vote
0answers
15 views

Making function calls exclusive per block

I have the requirement that in my smart contract certain functions cannot be called, if another function already has been called inside the same contract during the same transaction. Imagine I have ...
0
votes
0answers
6 views

does the gasleft function return the total gas left for the transaction or the gas left for the function call

If a function is using the gasleft() function and is called by another smart contract, does it return the total gas left for the transaction or just the gas left passed to the function via the message ...
0
votes
2answers
32 views

How do oracle services interact with logs?

I am approaching blockchain and smart contracts for the first time and I have trouble understanding some concepts. I read this article https://medium.com/decentlabs/building-your-first-ethereum-oracle-...
0
votes
0answers
5 views

Can not get a clear solcjs compile!

I've created my first smart contract and it compiles clear and deploys using Remix. But in node js when running "node compile.js", I get no output generated in the build folder. The code is ...
0
votes
0answers
18 views

gas_estimate returning error for too man arguments

running Web3 5.13; python 3.9; Mac 10.15.7 Trying to run test on solidity contract based on the example provided in teh Web3.py docs. When running this I receive an error stating TypeError: ...
0
votes
0answers
12 views

How much is cost to deposit some ETH from 10 EOA address to a smart contract and withdraw the funds to one EOA address? [closed]

How much is cost to deposit some ETH from 10 EOA address to a smart contract and withdraw the funds to one EOA address? I want to know how much gas-limit is need to execute it? deposit part ...
0
votes
0answers
9 views

Deploying MakerDAO Oasis on Kovan Testnet

I'm trying to deploy MakerDAO Oasis on Kovan Testnet & Ganache but I'm struggling to figure out how to do so. The error shown occurs when I use my metamask, on Kovan network, to try and create a ...
0
votes
1answer
16 views

ERC20 Interface

When you make a token, must you have an ERC20 Interface (such as the one below)? What is the purpose of it? pragma solidity 0.6.6; /// @notice ERC20 https://eips.ethereum.org/EIPS/eip-20 with ...
0
votes
1answer
26 views

Staking reward distribution in a month

I was just wondering, how would I be able to make a staking function that, after one month, distributes "x"% to the locked up stake holders? Is it something to do with now and ...
0
votes
0answers
27 views

What does this solidity code do in crowdsale contract?

Trying to level up on my solidity skills. I understand most of the crowdsale contract except these lines balances[teamWallet] = 3000 ether; emit Transfer(address(0x0), teamWallet, (3000 ether))...
2
votes
0answers
20 views

Transforming random number into normal distrubution

I am looking to transform a random number into a normal distribution between 1-20. I have been looking to implement the box muller transformation to do so. But can someone point me an easy way to do ...
0
votes
1answer
10 views

How to pass IERC20 as argument in solidity?

i'm trying to deploy sushiSwap on my local machine. but i don't know what should i pass a argument in constructor... code is like... pragma solidity 0.6.12; import "./IERC20.sol"; import &...
0
votes
0answers
31 views

Error : Called function should be payable

I am trying to create a token contract and the token sale contract. Token Contract : ERC20 token is ready and it is flawless TokenSale Contract : I have passed the "Token"" contract to &...
0
votes
0answers
12 views

Frontend for OpenZeppelin ERC20 token and Crowdsale

does anyone know if there are any resources online for a front-end app.js for a simple ERC20 token for a crowdsale? I am looking to build out a front end that will allow log-in with Metamask and buy ...
1
vote
0answers
36 views

the change of storage trie tree when the data in smart contract is changed

As we all know,the data in smart contract is stored in storage trie tree. If the data of a smart contract is modified, will a new storage trie tree be generated, or will the data is modified on the ...
0
votes
1answer
19 views

Simple contract to contract token transfer failing

I'm trying to write a contract that combines two different function calls into one transaction, for which I then can hopefully use the CHI gas token. However, for now I can't even get my contract to ...
1
vote
1answer
41 views

Preserve msg.sender but not storage

In this particular scheme, we pass the address of the Attacker contract in Victim.foo. By using delegatecall, we maintain the msg.sender field, but we are not using the storage of Storage but Attacker'...
0
votes
1answer
22 views

whether the value stored in levedb in Ethereum can be changed? [closed]

I can store some key-value pairs through smart contracts in Ethereum, and this key-value pair will be stored in levelDB. But why can I still modify this key-value pair? In my opinion, the data stored ...
0
votes
1answer
21 views

How can I listen to certain contract's method's changes?

Let's say I have a method: function appendNewName(string name) { names.push(name); } I want to store this in the backend in DB once a new name is inserted. How can I achieve that? Unfortunately ...
0
votes
1answer
21 views

Withdraw function in my staking dapp not working as it should

I'm making a staking dApp (tutorial project) and my withdraw and reward function that is to be called when the msg.sender wants to stop staking doesn't work well. The function calls and returns a ...
0
votes
1answer
29 views

Encode data into a single bytes variable using assembly

I'm currently testing a few things using the Solidity assembly. Basically, what I want to do is Pack several variables of different type together into one bytes array i.e. similar to what abi....
5
votes
0answers
27 views

Deploy gas issue for require reason string

I found a strange case and didn't find out why. ... modifier onlyMaster() { require(msg.sender == master || msg.sender == developer, "caller is not the master"); _; } ... ...
0
votes
0answers
10 views

How to get transaction Status and data regarding that transaction in web3js?

I have a Dapp where user can buy and send ERC20 token whose bussiness login written in Smart contract..Now when someone buy the token, how do I know in web3 that how much token they've bought and what ...
2
votes
0answers
25 views

How to store array parameter of a function to contract state?

I am trying to save an invoice to contract storage (see function addNewInvoice(..)) but I seem to be tripping over the data locations. // SPDX-License-Identifier: private pragma solidity >=0.7.0; ...
0
votes
0answers
11 views

Translating Solidity into the Arabic language [closed]

I'm Arafat Bouchafra from Morocco, I'm a software engineer, and I'm very interested to translate the Solidity progrogramming language to the Arabic language, so kindly can anyone refer me to the right ...
1
vote
1answer
16 views

OpenZeppelin balanceOf(address) function Vs Mapping

The OpenZeppelin ERC-721 library has a function called balanceOf(address owner), which enables one to know how many tokens an address owns. Furthermore, one can also use a mapping in order to keep ...
0
votes
0answers
24 views

How to pass number as integer?

I have the following function from my smart contract. event NewClient(int id); function newClient (bool _state, string memory _link, int _daysRequired) public { numberofTransaction++; ...
1
vote
1answer
20 views

How to deposit to WETH in Solidity 0.6 and above?

Solidity 0.6.0 introduced a breaking change in how ETH transfers are performed. The following doesn't work anymore: weth.deposit.value(amount)(); What is the latest syntax for depositing ETH into the ...
0
votes
1answer
8 views

Invalid implicit conversion from contract to address

pragma solidity 0.5.10; contract ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address _owner) public view returns (uint balance); function transfer(...
0
votes
1answer
19 views

Using Chainlink External Adapters doesn't return anything

Trying to use this Bitcoin Adapter But having some issues specifically with the copyPath argument and the callback arguments. For one, I would like to retrieve multiple parts of the JSON that is ...
0
votes
0answers
9 views

How do I create a Token Tracker for my ERC20 token on Etherscan? [closed]

On the Ropenstine Test Network, It took only a few seconds for my ERC20 token to have a tracker page. Not a contract page, but the ones that say "Token: (Token Name)". Here's the contract: ...
0
votes
1answer
30 views

Web3/JS: Unable to read a “public view” function using “.call()” while the call to the other functions (eg payable, etc…) work fine

I am posting a question here that I already posted on stackoverflow before I was aware of this ethereum forum. Not sure about the etiquette when doing this so please tell me if I should delete the ...
1
vote
1answer
17 views

Retrieve Uniswap tx data in my solidity smart contract

As the title says, I have my Solidity smart contract and I am trying to import in ti some public data from the Uniswap contract. In particular I would like to have the tx data stored in my contract (...
3
votes
3answers
174 views

Does it cost gas if a non view/pure function does not alter the blockchain?

Say I have a function which 'might' alter the state of the block chain depending on conditions. Will I get charged gas if it does not? For example: if (conditionMet) { ...
0
votes
0answers
12 views

type conversion from fixed and ufixed to string

i have a contract and within the contract i have a function which takes two variables from the input from the user, one of them is integer and one of them is double (both are necessary to the ...
0
votes
1answer
19 views

Best Practices for Verifying Ownership of an NFT ERC-721 Token

I am developing a Smart Contract (SC) and a front-end Dapp which will be used to sell some NFT ERC-721 tokens. When a user/address buys one of the NFT tokens, the token will be minted to his benefit ...
0
votes
0answers
15 views

transact to Auction.placeBid errored: VM error: revert. revert The transaction has been reverted to the initial state

I signed up for a "introduction to Blockchain" course in my exchange semester in South Korea and I feel like it's not just an introduction because for half of the final grade we get we have ...
0
votes
0answers
7 views

Blockchain & Solidity : Could you someone explain me what function entrySet is for?

I found this code online.It's about notorization of some document. I need to understand this code real quick. So could you tell me what function entrySet(bytes32 _checksum) do? pragma solidity ^0.5.0; ...
0
votes
0answers
42 views

Unhandled Rejection (Error): call revert exception [closed]

I am getting this error message when trying to interact with my smart contract on my react front end. I ran npm start, and my localhost3000 popped up with the error message below. Note, metamask is ...
0
votes
0answers
11 views

Solidity contract function encode / decode parameters for mapping states [closed]

If I was to want to migrate a contract with all the current mapping states of the current deployed contract would there be anyway to decrease my gas cost by being able to encode / decode values from ...
2
votes
1answer
132 views

The endpoint returned a different chain ID: 0x539 (Ganache)

I am trying to connect Metamask to ganache by creating a custom RPC with the following details: New RPC URL: HTTP://127.0.0.1:7545 Chain Id: 5777 But I keep getting the error message The endpoint ...

1
2 3 4 5
183