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

How to concatenate 2 uint into 1 uint?

What is the most efficient way to concatenate 2 uint variable values into 1 uint variable value?
1
vote
1answer
3 views

Can I read block.coinbase of the current block?

I'm looking into some Solidity functions and block.coinbase caught my attention. It returns the address of a block's miner. Can it be read for the current block or just for previous blocks like ...
0
votes
1answer
5 views

Keep an old Solidity version token, or update it for new contracts development

I am working in a project with an ERC20 token generated with Solidity 0.4 (but for the moment, all the tokens are in the owner's address). Community already knows this token address, and knows that it ...
0
votes
1answer
11 views

Construction function

My construction function accepts three arguments, one of which has to be a specific amount written in Wei. Whenever I try to compile and migrate my contract an error shows up notifying me that number ...
0
votes
1answer
6 views

It is safe to use OpenZeppelin v2.5 contracts (Solidity 0.5.0) in 2021?

I was checking some pretty old contract samples of OpenZeppelin v2.5, and they are in Solidity 0.5.0, and I am not sure if it is a safe version, or not. If I extend these types of contracts, it makes ...
0
votes
0answers
7 views

How to sync liquidity pool on Pancakeswap with the BSC Testnet?

I'm using this PCS clone on the testnet: https://pancake.kiemtienonline360.com/#/swap And I'm trying to understand how an elastic token works. I'm looking at Gravitoken (https://bscscan.com/address/...
1
vote
1answer
27 views

What does msgSender() this code do in the OpenSea repository's example ERC721?

abstract contract ContextMixin { function msgSender() internal view returns (address payable sender) { if (msg.sender == address(this)) { bytes ...
0
votes
1answer
13 views

Smartcontract that receive tokens and ether(native BNB) and swap it through pancakeSwap router?

i am creating a smartcontract on BSC which receive specific BSC tokens and transfer it to smartcontract. and then using Pancakeswap router to swap that token to MyOwnToken. but i am unable to ...
0
votes
1answer
6 views

Deploying 'dydxprotocol / solo' results "Error: spawnSync /bin/sh ENOBUFS"

I'm running in Amazon cloud9 https://github.com/dydxprotocol/solo running 'npm run deploy_test' At some point of the contracts compilation (maybe the end) I get the ENOBUFS error. Is that something in ...
0
votes
0answers
8 views

Supply chain contract cannot pay

I have a supply chain contract and the basic idea is: in itemManger contract: create an item where input string and uint. For example, "Iphone", 123. input 0 into item function 0: address: ...
0
votes
0answers
15 views

Simple eth sending tx won't work

Why doesn't this work on remix? It compiles the contract but when you execute 'f' it reverts back the tx and sends the error message. pragma solidity 0.8.7; contract Testing44{ uint256 amount = ...
0
votes
0answers
17 views

Possible to set a minimum price to mint an NFT

Is it possible to set a minimal price through smart-contract (Solidity) when an NFT is minted?
0
votes
0answers
5 views

Using different accounts for executing a function in solidity unit testing

I have written a smart contract and within which I have declared a payable function where everyone could send their funds to the contract. Once they have transferred their funds, they would have the ...
0
votes
0answers
8 views

Could I use block.coinbase or block.timestamp to generate pseudorandomness? [duplicate]

Trying to generate some randomness without using VRF or commit/reveal. It's for a small priced NFT (about 100 dollars) so it's much less than the block reward. My idea is to hash together 3 variables: ...
0
votes
0answers
8 views

Fail to perform 0x swap on local hardhat network

setup: hardhat typechain local hardhat network (forked mainnet) ethers (hardhat) mainnet token addresses I'm using the 0x /swap/v1/quote to quote 2 tokens. async quote(buyToken: Token,sellToken: ...
0
votes
0answers
17 views

can I change loop logic to an alternative logic in this staking contract?

I built a staking contract that allows users to enroll in auto compounding through a function that is basically adding the user address to an array UserList Now for auto compounding I have these ...
0
votes
0answers
9 views

Add new token to ERC1155 contract

I'm working on building out an ERC1155 contract where a user can add a new token with the required metadata to my existing list of tokens. Is this possible with ERC1155? How would I go about doing so? ...
0
votes
0answers
3 views

TypeError: Cannot read property 'getAmountsIn' of undefined BSC Price Bot

new to dapps and newer to coding here - trying to create a pricebot for BSC. As of right now I am only trying to integrate PCS (if I can get thi s to work I'll obviously add more). I am getting this ...
0
votes
0answers
12 views

Custom ERC-20 Token without Price Oracle available

I'm currently in the process of creating a custom ERC20 Token, that tracks an underlying commodity. There is no price oracle for this commodity, so I was looking at ways in which I am able to create a ...
0
votes
0answers
13 views

Issue with assigning arbitrary values to .call{value: msg.value}

Just learning Solidity here. I am trying to pass an receiving address, and an arbitrary amount (other than msg.value) to my transfer function, but it is just not working for me. This is the code: ...
0
votes
0answers
7 views

Request multiple random number at once on chainlink VRF

Would it be possible to require more than one random number on the chainlink VRF with only one call to requestRandomness or any other function ? Thank you
0
votes
0answers
10 views

Can I get the hash of any past block using Solidity? [duplicate]

Is there a limit of blocks ago that I can get the hash of within solidity using block.blockhash()?
0
votes
0answers
13 views

Remix - Create new file not working

I'm literally just trying to create a new file in remix and it is not working. Same goes for new folder. When I try to create a new file/folder the empty bar appears for me to type in and yet I cannot ...
0
votes
0answers
15 views

Convert string into uint256

How would I go about converting a string from a parameter in a function into a uint256. Example of a string: "220000000000000000"
0
votes
2answers
13 views

ProviderError: max code size exceeded - Hardhat

Iam trying to deploy a contract in ropsten testnet using hardhat but its throwing max code size exceeded error. i tried this example bud didn't work added (allowUnlimitedContractSize: true) but didn'...
0
votes
0answers
8 views

Can't use payable function of other contract

I wrote a contract which I will deposit eth in and this contract should mint on another contract, but it does not seem to work. Why? Here is my code: pragma solidity ^0.8.0; //SPDX-License-Identifier: ...
0
votes
0answers
5 views

how do i change the price feed token from eth /usd to busd/usd with the chainlink oracle?

I am trying to get the price feed for BUSD/USD using the chainlink pricefeed oracle but it tells me that the code was reverted. this is also happening when i switch to any other token, i am using the ...
1
vote
0answers
12 views

Possibilities in Solidity

I want to create an NFT crowd sale contract. I have 4 egg. People will buy them with possibilities, I mean for exp: 1st egg's chance is 1%, 2nd is 5% and so on. What is the best way of doing this?
0
votes
0answers
8 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
3 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
12 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
0answers
16 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? ...
0
votes
0answers
14 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
5 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
2answers
77 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: ...
0
votes
2answers
14 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 ...
0
votes
0answers
14 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
7 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....
0
votes
1answer
14 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
6 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 ...
0
votes
0answers
9 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 ...
0
votes
0answers
6 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 ?
0
votes
1answer
24 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 ...
1
vote
1answer
23 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) { ...
1
vote
1answer
30 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
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 ...
1
vote
1answer
12 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 ...
0
votes
0answers
14 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 ...
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
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 ...

1
2 3 4 5
229