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

How does ERC2309 implementation differ or change a standard ERC721

My understanding of the ERC721 minting process is that it follows three basic steps, it updates the owners balance (mapping _balances), it makes a record, associating the tokenId to the owners address ...
4
votes
1answer
1k views

how to call smart contract function in C#.net core

protected async void Page_Load(object sender, EventArgs e) { var senderAddress = "0x605a1f8d368cbdd4d0a5cbad74f75c428660f17b"; var password = "zxcasdqwe123"; ...
1
vote
0answers
5 views

Solidity PRNG with future block hashes: reasonable secure?

I would like someone to tell me if I am neglecting serious security concerns here. I Am trying to create a Solidity slot machine where hash puzzles (leading zeros) are used to get various jackpots. ...
0
votes
0answers
5 views

Issue in the creation of DAG “bash create_dag.sh”… need help..?

While i go with this command "bash create_dag.sh", i found some errors which are shown in snapshot. how can i overcome this issue..?
1
vote
1answer
11 views

get a list of all erc20 tokens including address and decimals

Is there a way to programmatically fetch a list of all erc20 tokens including contract addresses and decimals? Im using web3 but if there is any rest service I dont know Im happy to get to know about ...
0
votes
0answers
14 views

Receving Error “'Migrations'— invalid sender” during deployment to BSC mainnet

I have tried each of the suggestions mentioned in the official issue pointing to this problem to no prevail in BSC MainNet. I have had success in BSC TestNet as well as Ropsten TestNet. However, the ...
0
votes
0answers
13 views

Monitor transfers to given addresses

I have a program that monitors all token transfers going out from a set of addresses I have. That works fine, I get the transactions, the tokens, the amount etc. But now when I apply the whole logic ...
0
votes
1answer
14 views

Function and withdrawal does not recognize the address as payable

I have this withdrawal function but an error happens: TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". -...
0
votes
0answers
9 views

Percentages with Big Numbers Truffle Test

I am trying to find a percentage using the Big Number library from @openzeppelin/test-helpers Here is the code: var someVarABC = new BN('2706'); var someVarDEF = new BN('5060584'); var total = ...
2
votes
1answer
30 views

Link a library to a smart contract only with Solidity and bytecode

I work in Truffle development environment and use Windows PowerShell. My code is a test code and is simple. There is a library called Alireza that just compares two uint values. There is a contract ...
1
vote
0answers
5 views

What does add(source, 32) do in solidity?

I understand what add() does. It used used in the assembly to perform additions. My question is why are we adding 32 here? What is the purpose of doing so? The full code is here
2
votes
2answers
1k views

How to transfer Ether to ERC20 token contract?

I have a function that needs to make transfers to a token smart contract as well as personal accounts upon satisfaction of some conditions. function completeSale() onlyOwner public { if (...
0
votes
0answers
7 views

Different number of arguments in return statement than in returns declaration in solidity smart contract [closed]

I'm getting an error next to return that says "different number of arguments in return statement than in return declaration" for(uint i = 1; i <= medicine_count; i++){ if(medicines[i]....
4
votes
2answers
881 views

Importing a contract from another contract in NodeJS app

I'm using a function in my NodeJS app to deploy contracts. The user inputs the contract he wishes to deploy and the app deploys it. The structure of the app is . ├── app │   ├── models │   │   └── ...
2
votes
0answers
15 views

1) “before all” hook: prepare suite for “ ”

I am trying to create an Integrated test (to test multiple smartContracts working together). I re-initialize them inside beforeEach() function. So I get the clean test for each test case. I have done ...
0
votes
0answers
24 views

ALERT: Transaction Error. Exception thrown in contract code. Metamask while interacting with contract

When I try to interact with my contract (.vue, Web3) via Metamask browser extension, I get the warning "ALERT: Transaction Error. Exception thrown in contract code." when I attempt to buy. ...
4
votes
3answers
442 views

Hardhat - How to interact with a deployed contract?

I can deploy a contract using ethers and Hardhat with the following: const myContract = await hre.ethers.getContractFactory("SomeContract"); const deployedContract = await myContract.deploy()...
0
votes
2answers
566 views

How many tokens are transfered actually when we are using decimals

I have a code below and when I am transferring 1,695,000,000 to a particular address, so actually 0.000000001695 are being transferred. Why is it so? Does that mean to transfer 1.695 billion tokens I ...
2
votes
1answer
412 views

msg.sender not address payable? (Solidity 0.8.2)

I've switched from Solidity 0.7.2 to 0.8.2 And the addresses declared as payable (owner) are reporting they are "NOT payable" in the contract. pragma solidity ^0.8.2; contract MyContract { ...
1
vote
1answer
68 views

what's the point of merkle distributor?

I am trying to understand why Merkle Distributor AKA merkle airdrop is used. I understand how it works, but what I don't understand is why it's a better option. People use it when there's ICO and they ...
0
votes
1answer
403 views

Smart Contract Deposits From Multiple Users

I want to create a smart contract which will allow multiple users to deposit / withdraw funds. My first approach was to simply have one contract address which will store the funds of all users and a ...
0
votes
0answers
6 views

Issue interfacing smart contract with the front end

I'm actually trying to write a simple smart contract with front end that takes a value from the user and saves that in the variable in the smart contract. The index.html part of my project is <!...
1
vote
2answers
1k views

How do I add value to an erc20 token already deployed?

The contract is 0x1b016Ac4De0996b1f59EaB9c54A083aF496C811D. For now my token shows no value. I would like each token to start from a value of 0.0001 Eth. Thanks
1
vote
0answers
95 views

What is the best secured way to let users interact with a tokens minting function?

I have an ERC20 tokens contract with a function to mint tokens. This function allows users to mint tokens after performing specific actions or activities on a website. If a user performs the action ...
0
votes
0answers
14 views

approve + safeTransferFrom ERC721 from existing smart contract

I am trying to call ERC721 from another smart contract, while calling function approveAndTransfer ,I am getting "ERC721: transfer caller is not owner nor approved", not sure reason behind it,...
0
votes
1answer
20 views

1INCH Version error

I got error importing and using 1INCH. The problem is in the versions. In IOneSplit.sol version is 0.5.0 (pragma solidity ^0.5.0). And IOneSplit imports IERC20 which is in 0.8.0 (pragma solidity ^0.8....
0
votes
0answers
9 views

Solidity: solidity declarationerror identifier not found or not unique

Trying to create my first smart contract with the REMIX IDE, however getting into a Declaration Error. Here is the code of my contract : // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.2; ...
1
vote
0answers
15 views

Computing the Uniswap V3 pair price from Q64.96 number

I am trying to compute a Uniswap v3 pool prize. I can get the square root price of Q64.96 number as uint160 (e.g., 1234217676608908277512433764 - value of DAI/ETH pool (price at that time around 1 ETH ...
1
vote
1answer
54 views
+50

price conversion using chainlink ETHUSD price

I'm storing a product's USD value in contract. mapping (string => uint256) productUSD; For example, if it's $52 I'd store it as productUSD[_product] = 52; Now, when people paying in ETH, I want to ...
0
votes
1answer
208 views

Error ; Member “push” is not available in address[] memory outside of storage

I am writing a function to generate trail of all address who owned an asset ( assets is a mapping of asset no to owner no to address of owner). However while making array of address 'listofOwners' I ...
0
votes
0answers
20 views

Fail with error 'UniswapV2Router: EXPIRED'

I forked UniswapV2's factory and router and deployed them in Kovan using remix I also made sure that I am sending an ETH I also made sure that I approved the tokens But I am getting this error when ...
0
votes
0answers
27 views

Copying a smart contract and deploying to Test

I copied the Safemoon contract and deployed it to BSC Testnet for study purposes. However, it does not work as expected. I used REMIX for the IDE. The TokenName does not appear as it usually does when ...
0
votes
1answer
15 views

Solidity - Interface & ERC-165 by OpenZeppelin

I am struggling to understand this below implementation of the ERC-165 standard by OpenZeppelin. This is by default imported in the ERC721 token smart contract of OZ. I do get the aim of the ERC-165 ...
2
votes
2answers
906 views

Solidity Event logs

I have a JS code which is connected to ganache. I am trying to call a solidity function which in tern emit the event. In JS i am watching the event. Now when i call the function first time it sets ...
0
votes
1answer
16 views

What is the Intent of smart contract and decentralization

I have just started on blockchain and found that there are two key benefits with Ethereum: smart contract and decentralization. I tried to understand the benefits they provide and why they could have ...
0
votes
0answers
14 views

how to calculate create2 ? convert solidity to node/python [closed]

anyone can convert this code to nodejs? function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) { // solhint-disable-next-...
1
vote
1answer
612 views

C# - Convert Ethereum ABI Address To String (Solidity)

I'm new to Ethereum so please excuse my ignorance. Ethereum seems to have an ABI serialization protocol called Solidity. The spec is here: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI ...
0
votes
0answers
10 views

tokenFallback and transferAndCall and approveAndCall?

Excuse me, what data should I pass in _data bytes when I call tokenFallback and transferAndCall and approveAndCall? function transferAndCall(address _recipient, uint256 _amount, bytes _data) ...
0
votes
1answer
11 views

Linter Error: `assert(this.f.address == address(this));`

While learning solidity, I copy-pasted this code from: https://docs.soliditylang.org/en/v0.8.4/types.html // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.4 <0.9.0; contract Example { ...
2
votes
1answer
109 views

Modifying simple function with inline assembly

I'm trying to write a super simple contract that's gas efficient utilizing inline assembly in solidity. All this function needs to do is create a child smart contract with one function, self destruct....
0
votes
0answers
28 views

How do I add fees to my ERC20 token? (for redistribution, liquidity and a dev wallet)

Thank you for reading this post. I can make a basic ERC20 token, but I am really struggling to find anything that explains how to add fees. My intention is to create a token with 3 fees. One fee will ...
1
vote
1answer
91 views

Hiding values from calculation (zkSnarks?)

In reference to a calculation of a hidden stored value. For example: Account A & Account B Both have hidden stored values. Accounts A cannot know B's hidden stored value, and vice versa. Is ...
0
votes
1answer
114 views

How can I distribute funds to present stakers efficiently?

I am building a smart contract which keep the token holder's eths for a while and give them rewards when they withdraw. The reward is given from the ethers collected by early withdraw of people. If ...
2
votes
0answers
16 views

Binance Smart Chain tokens: What are tTotal, rTotal, tSupply, rSupply, rOwned, tOwned which I see everywhere?

Looking at all the latest shitcoins' Smart Contract code on Binance Smart Chain, there's a lot of common,recurring themes because most of each project's code is mostly copy-pasted. The code is also ...
0
votes
0answers
7 views

Use ERC165Checker library function in web3

As I understand the ERC165Checker library provides the _supportsInterface function which takes a contract address and an interfaceId and returns whether that contract has the specific functions. How ...
0
votes
1answer
130 views

Ganache Storage

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something ...
0
votes
1answer
50 views

Constructor error on multiple pieces of code - Remix

I've been getting this error when I try and deploy a contract with a constructor on multiple pieces of code. I use the correct complier version too creation of MyContract errored: Error encoding ...
3
votes
2answers
4k views

Is the Gas Fee refunded if the transaction fails?

I'm confusing the rule of paying gas fee when caller makes a transaction. The gas fee is needed when the transaction is made and I know that the require() is the guard function that returns all the ...
20
votes
5answers
27k views

Source File requires different compiler version

I am using solidity version "pragma solidity ^0.4.20;". When I checked JSON files of contract, compiler version shows : "compiler": { "name": "solc", "version": "0.4.21+commit.dfe3193c....
2
votes
2answers
108 views

Solidity - Proper way to Import Contracts

When importing one Solidity contract into another, what’s the difference between importing it and accessing it using the is keyword, vs. importing it and just instantiating an object of it? Here’s ...

1
2 3 4 5
203