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

Getting Error : ERC20: transfer amount exceeds allowance

contract Token is ERC20 { constructor() public ERC20('DonkeyCoin', 'DKC'){ _mint(msg.sender, uint(100 * 10 ** uint(decimals()))); } // now we can make the approve for the msg.sender the amount it ...
2
votes
4answers
3k views

How to fix "No events were emitted"

I have been following the instructions in the Dapp university tutorial. But I am using Windows 10, Dapp University is Mac. I downloaded this truffle with smart contract ERC20 from Dapp university. ...
0
votes
0answers
4 views

Truffle compile error. ParseError: Expected ';' but got '}'

I am trying to compile my contract but I get ParseError while compiling Migrations.sol. I got this error after running E:\blockchain-learning\hooks-truffle-ganache>truffle develop truffle(develop)&...
0
votes
0answers
2 views

About Solidity Syntax Bracket

pragma solidity ^0.6.6; contract MyContract { function someFun() public { (bool success, ) = address(this).call{value: 1 ether}(abi.encodeWithSignature("someOtherFunction(uint256)&...
0
votes
0answers
3 views

subdivide the hash by parts

// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; contract Substring { function substring(string memory str, uint startIndex, uint endIndex) public view returns (string memory) { ...
0
votes
1answer
13 views

Looping Through an Array in Solidity?

Having a difficult time with loops and arrays in Solidity. If i have a simple contract like below (no mapping, just a struct array), is it possible to loop through the array to get a particular ...
0
votes
0answers
7 views

How to fix: The called function should be payable if you send value and the value you send should be less than your current balance?

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract T1 { function shuffleArray(string[5] memory _dnaArray) public view returns(string[5] memory) { for (uint256 i = 0; i ...
1
vote
1answer
82 views

Error installing eth-brownie in MacOS

I call pipx install eth-brownie and get this error: pip failed to build packages: bitarray cytoolz lru-dict Some possibly relevant errors from pip install: fatal error: too many ...
0
votes
2answers
410 views

Truffle Install // npm WARN and Vulnerabilities -- How i solve that issues?

I want to start working with Solidity in my Visual Studio Code so i installed Visuall Studio Code first, then nodejs and npm and in the end i try to install Truffles. -I work on Window 10 OS -Nodejs ...
0
votes
0answers
5 views

Difference between Static and Dynamic Memory Arrays

I was looking at the documentation and was looking at arrays stored in memory. Now, the documentation said that arrays stored in memory cannot change their size using .push() or .pop() functions. This ...
0
votes
1answer
365 views

Factory Contract Function is not creating New Contract using testrpc and web3

I am new to DApp development. I have deployed a TokenFactory contract and that Factory contract has a function "Create New Token" that generates a new token contract. The function "Create New Token" ...
1
vote
1answer
767 views

Where is the compiler in Remix?

I installed remix-ide. It is able to compile contracts. So it somehow calls Solidity compiler. Where is this compiler located in the filesystem and how to use it without remix-ide?
0
votes
1answer
49 views

How to code a string replace function in solidity?

I'm looking for a function that approximates the functionality Ruby's gsub or javascript replace. So you could do something like replace("Too many horses are horses","horses", &...
0
votes
0answers
9 views

Solidity re-entrancy attacks and how to guard against them

I'm trying to understand re-entrancy attacks. Is tip1() below at risk of a re-entrancy attack (if the fallback function of the miner's contract invokes tip1() itself)? And if so, is tip2() safe? ...
1
vote
1answer
19 views

Passing Strings by Reference

I have two pretty simple questions: 1) // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract Test { function testing() public pure returns (string memory) { ...
0
votes
2answers
10 views

Should external non-pure functions have any return values?

Does it make sense for a non-pure/non-view external function to return any values at all? This is especially when this external function is likely going to be called off-chain. Since they are likely ...
1
vote
1answer
19 views

Cannot call method with mocha

I am running some test in my first smart contract called Inbox.sol. I Want to call the method .message in order to see if it is equal to the default variable I use when I deploy the contract with web3....
0
votes
0answers
4 views

Looping over array with array length as condition

Say we have a contract with a dynamic state array fooArray of uint256. At the same contract there is a function with the following loop: for (uint256 i = 0; i < fooArray.length; ++i) { // Some code ...
0
votes
0answers
4 views

Guard function for incoming ERC721-ERC1155’s

I have contract 1 which generate ERC-1155 tokens. And I have contract 2 which work with this tokens. How properly receive and approve my tokens in contract 2, only if they belong to contract 1 creator ...
0
votes
0answers
10 views

having a problem with solc-x version "solc 0.6.0 has not been installed"

I m trying to print out the variable (compiled_sol) as you will see in the code below of the python file named deploy.py so I can deploy my smart contract, but I keep running at this error *****INFO: ...
1
vote
2answers
434 views

zeppelin-solidity Crowdsale. Access to token using javascript

I'm trying to use javascript to access the token variables and functions provided in the MintToken.sol file in openzeppelin. I used "truffle init webpack" to create the metacoin example provided by ...
1
vote
2answers
52 views

Creating an ERC20 faucet

I am trying to use this https://github.com/marvinkruse/simple-faucet what line number do I put in the address of my ERC20 token? Is it line 16? and is it "address" or "_tokenInstance&...
0
votes
0answers
13 views

Where to find somebody to help/collaborate on a project with(Solidity)? [closed]

I was looking for a developer, couldn't find anybody. It's either (mostly) incompetent developers from third world that wasted me a lot of time, or they are too expensive(charging 150$/hr). So instead ...
0
votes
0answers
5 views

payable function

function chance(string memory str) public view returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(4); for(uint i = 8; i < strBytes....
1
vote
1answer
403 views

Weighted Random Number Array generation in solidity

I have an array like this in the array, uint256[] public numberArr= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; Each number in an array have their own weight, uint256[] public weightNumberArr = [1, 3, 9, 7, 15,...
0
votes
0answers
4 views

Multi-user Smart Contract Wallet Concept

I am relatively new to Solidity development, I'd like any thoughts or warnings about this type of implementation. It is not complete as far as receiving ERC20 tokens goes, or checking ownership, it ...
1
vote
1answer
815 views

Invalid number of arguments error for getter function with no passed arguments

I am receiving this error when trying to call the getUsers getter function from the contract below: Invalid number of arguments to Solidity function. Running on Truffle in develop mode. mapping (...
0
votes
0answers
8 views

Can't get revert reason (TransactionRevertedWithoutReason)

I'm making some tests on kovan network to execute a flash swap on uniswap. But for now I have reduce my probleme to this : // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ...
3
votes
1answer
493 views

Full Integration Testing smart contracts

What is the most agile way to fully integration test smart contract code? I've seen people use shell, etc. Is there a golden standard somewhere?
0
votes
0answers
5 views

what are the steps to execute this contract

I want to execute this program https://solidity-by-example.org/signature/, but I do not know where should I run web3 code any one can tell me the hole steps that describe how to run this ?
1
vote
1answer
9 views

How to securely decrypt game data inside smart contract

I have a problem I haven't been able to figure out, as follows: Suppose I have a game running on the blockchain (a solidity/smart contract game) where there are a limited number of plots of land that ...
4
votes
3answers
432 views

metamask eth_sign can't make it work

I have this: ethereum.request({ method: 'eth_sign', params: { from: account, //this is the address message: '0xfafa' } ...
0
votes
1answer
30 views

Solidity: How to represent bytes32 as string

This may be simple in other languages but I can't figure out how to do it in Solidity. I have a bytes32 like this 0x05416460deb76d57af601be17e777b93592d8d4d4a4096c57876a91c84f4a712. I don't want to ...
1
vote
1answer
20 views

Cannot read properties of undefined (reading 'address')

Im trying this Solidity and VueJS tutorial from MEDIUM. I even git cloned the github sourcecode, but I keep getting this error on the browser console: ERROR 1: Error initializing Drizzle. ERROR 2: ...
0
votes
1answer
292 views

Modifiers misunderstanding

pragma solidity ^0.4.0; contract test { bool test_bool1 = false; bool test_bool2 = true; modifier test_modifier(bool _test_bool){ if (_test_bool == false) throw; _; } ...
0
votes
0answers
3 views

Writing ByteCode with as few opcodes as possible

So I'm very new to understanding assembly. So with this blog: Magic Number Ethernaut Writeup , I have learnt how to return a value from a contract irrespective of what function is called, with as few ...
0
votes
1answer
116 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 ...
0
votes
1answer
158 views

Why is my Crowdsale Contract not letting me buy?

Good day, I have designed a mintable token that has a max supply, I now want to sell that token in a Crowdsale. I created the crowdsale contract, set the token address, transffered the funds... but ...
0
votes
1answer
11 views

String to Bytes Converts to Incorrect Value

I have a string array stored in memory as https://cloudflare-ipfs.com/ipfs/QmSXDsFeNaPa3CJKmn8WKBnA421Zv5r3Ra8n71LZhvEi9s This should convert to ...
0
votes
0answers
13 views

Is there a way a smart contract can know the price of a token?

I have a question. Is there a way a smart contract can know the price of another token. I want to create an ICO smart contract whereby if the user sends BNB to the smart contract, there is a fixed ...
0
votes
0answers
2 views

Halt Trading on BEP20 or ERC20 token?

I am trying to halt trading on my BEP20 token. How do you do that in BSCscan complier?
0
votes
0answers
16 views

Uniswap doesn't work with my fee function - looking for some assistance

I'm really stumped on this one, and hoping someone might be able to point out my mistakes. I'm far from experienced with Solidity, but was unable to find any kind of solution online for this specific ...
0
votes
0answers
9 views

How to walk down an API when making a chainlink get request?

Am trying to make a chainlink Get>Bool httpget request on the fantasy premierleague API but keep getting a false response. my code is: ''' function getGwstaus() public returns (bytes32 requestId) ...
0
votes
0answers
7 views

Expected primary expression. while using compiler version 8 [closed]

code was compiling ok on version 6:12 but giving this error on version 0.8.0 here is the full code;https://github.com/coderbang1/compiler-error/blob/main/error%20file here is the code constructor () { ...
0
votes
0answers
3 views

Owner required balanceOf prevent wallet from showing account balance

I am new in solidity smart contract development and i am handling a classic erc20token smart contract. I would know why adding this require condition balanceOf(address tokenOwner) { require (...
1
vote
1answer
21 views

how I can sign message using web3js?

I know that I can sign a message using web3js, but I don't know how I can do that, then how to verify that signature using ecrecover()?
0
votes
0answers
17 views

Mapping with conditions

Here is my structure struct userDetails{ address wallAdd; uint32 isUser; uint32 isAdmin; } I have to map records where isUser =1 only;
0
votes
0answers
13 views

How to add availability to receive another tokens as a payment

I created some kind of nft marketplace, deployed to BSC. So gonna use BNB as a main payment. Please advise how to solve the following questions: How to add additional ERC20 token as a payment that is ...
0
votes
1answer
159 views

The "from" field has been defined when sending a transaction, but the error still occurs

Problem I am following this tutorial on how to make a donate button on my React app. The tutorial is in HTML, however, so below is my attempt at converting it to ReactJS. Code App.jsx donate = () =>...
30
votes
3answers
39k views

What's the Solidity statement to print data to the console?

Sometimes it would be really helpful to be able to see string representations of variable values in the Geth console, like of argument values in functions. Can I somehow print them to the Geth console?...

1
2 3 4 5
229