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

nft market logic

If I want to implement a little NFT marketplace and want users to be able to put items up for sale, and other users to buy those, how should I do that? Do I need to make market contract that gets ...
0
votes
0answers
10 views

Is this possible ti pay for ERC721 token with other tokens not eth?

I want to create nft where people buy it using another erc-20 token not eth or bnb is this possible where to start?
1
vote
1answer
13 views

Can a mapping have defaulted value

An example of a a mapping mapping (address => address) yourNewMapping; Is there a way to have yourNewMapping[msg.sender] = defaultValue Say upon default through a constructor, for all users.
0
votes
0answers
13 views

I am trying to use chain link using remix

I'm getting this error /* Internal exception in StandardCompiler::compile: /root/project/libsolidity/interface/CompilerStack.cpp(93): Throw in function solidity::frontend::CompilerStack::CompilerStack(...
0
votes
1answer
13 views

Issue while testing a smart contract

Im getting myself into smartcontract development using solidity, I wrote the below smart contract and I have some issues with the Chai and Mocha test for the first function addCandidate() //SPDX-...
0
votes
1answer
15 views

Is there something in front of msg.sender?

Tx.origin is an old way of utilizing the handling address behind msg.sender. But let's say I, as a user, am calling a contract and that contract calls a contract. Is there a way for contract B... to ...
0
votes
1answer
8 views
1
vote
0answers
11 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
23 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 ...
1
vote
1answer
17 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 ...
0
votes
0answers
16 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
0answers
11 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 = ...
1
vote
0answers
7 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
0
votes
0answers
15 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
26 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. ...
0
votes
0answers
8 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 <!...
0
votes
0answers
15 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,...
4
votes
1answer
31 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 ...
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; ...
0
votes
0answers
33 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
34 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
17 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 ...
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-...
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
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
39 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 ...
2
votes
0answers
20 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 ...
2
votes
1answer
35 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 ...
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
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
14 views

JSON-RPC error when deploying contract

I am really new into contracts and tokens, I wanted to learn how to deploy a contract, so I grabbed someone else's contract and tried to deploy it on BSC. I was following tutorial on youtube and ...
2
votes
1answer
16 views

ERC721 Conforming to Contract Standards

When implementing the ERC721 contract standard, how strictly does one have to stick to the naming conventions of the method signatures - as spelled out by the standard? Take for example the ownerOf ...
0
votes
1answer
20 views

What are some practical use cases of the fallback function?

Besides receiving ethers, for which there is a dedicated receive function, what is a practical use case of fallback? I can't think of a case when it would be desirable for a contract to execute a ...
0
votes
0answers
12 views

Automatically tax transaction and distribute to all holder (Metamask, TrustWallet)

I was wondering if I e.g. use balanceOf(account[1]) += tax if the amount will also updated on Metamask and TrustWallet? Here is an example code which I found where the addresses will be in mapping and ...
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 { ...
1
vote
1answer
15 views

error: { code: -32000, message: 'invalid sender' }

I'm trying to deploy my Smart Contract onto the Rinkeby test network. Everything is working fine, my rinkeby account is also having enough ethers. And also using HDWalletProvider, I am able to access ...
0
votes
0answers
11 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
0answers
14 views

How to send a fixed amount of ether to a smart contract from an account?

Is it possible to send a fixed amount of ether to smart contract from an account every time a function is executed or button is clicked? No input fields should be used.
0
votes
0answers
11 views

Re-entry attack using the transfer function

Is it possible to re-attack if you use the sending of ethers via the transfer function? Do I need to add some defensive logic to my contract in this case?
0
votes
1answer
32 views

Passing an array to a function gets misinterpreted by the evm as value=20 causing INVALID_ARGUMENT error

I made an effort to cut out all the irrelevant parts of the code and get a minimal version still able to reproduce the error, these are the 3 smart contracts involved: // SPDX-License-Identifier: MIT ...
0
votes
1answer
17 views

DeclarationError: Undeclared identifier while it's declared

I get "DeclarationError: Undeclared identifier" on _totalSuppy and _balances. Could anyone help me figure this out? Parent contract pragma solidity ^0.8.0; import "./IERC20.sol"; ...
0
votes
0answers
13 views

how Burn mechanism work, Who calls the burn method?

I am wondering on how does the burning mechanism work, as far as i know, that who ever called the contract msg.sender will be his ethereum address. But the twist is when i saw the burn function, it ...
0
votes
1answer
14 views

Where can I find the source code for ETH 2.0?

Where can I find the source code for ethereum 2.0 and what programming language is it written in. Also, will this source code be rewritten into another language? And can I also run it and test it?
1
vote
1answer
16 views

Approve and Swap/Deposit at the same time

So one of the most annoying things for me is having to Approve before calling Swap or Deposit. I would love there to be a proxy contract which just calls Approve and Swap/Deposit in the same function. ...
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]....
0
votes
0answers
21 views

MasterChef contract - How to adapt masterChef to have buy back for each deposit TX?

Hi I actually try to modifiy this MasterChef from Blizzard : https://github.com/blzd-dev/blzd-contracts/blob/master/contracts/MasterChefV2.sol I wouldlike to take a part of fees to do a buy back on a ...
0
votes
0answers
8 views

Sending Token when the contract receives some value

I'm trying to make sure that, when my contract receives any token, send mine to the wallet of the person who sent it to the contract. event Received(address, uint); receive() external payable { ...
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 ...
1
vote
1answer
62 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 ...

1
2 3 4 5
204