Questions tagged [solidity]

Solidity is a language for smart contracts for blockchain technologies like Ethereum. It is designed to compile code for the Ethereum Virtual Machine. Use this tag for questions about programming smart contracts using the Solidity language.

Solidity is an object-oriented language whose syntax is similar to that of ECMAScript, but with static typing, and it is designed to compile to code for the Ethereum Virtual Machine for use in smart contracts in blockchain technologies.

6642 questions
1
vote
2 answers

Is it possible to predefine a winning number in Solidity and make it visible after some condition?

I want contract to predifine winning boxes, is it possible to achieve this functionality solidity, so no one can detect which box is the winning box? If so, how can I predefine winning boxes which will be unreadeable until the user opens a specific…
sbsb3
  • 23
  • 5
1
vote
1 answer

Why Openzeppelin ERC721 defines two 'safeTransferFrom'?

Source code: /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId,…
Ray
  • 333
  • 4
  • 11
1
vote
1 answer

How can I combine 2 smart contract functions in one transaction?

I am building two smart contracts, one is casino contract and the other one is lottery contract(planning to deploy it separately). I want to combine both the placebet(casino) function and buyticket(lottery) function in one call. Once user would call…
1
vote
1 answer

Solidity .transfer() function not forwarding funds

I have created a contract that creates an ERC20 token with no supply, and then once a donation comes, I want to issue a receipt of the equivalent of that donation in USD. So if they donate 10 MATIC, and its price is $0.8, my contract should mint 8…
Herbie Vine
  • 1,643
  • 3
  • 17
  • 32
1
vote
1 answer

Allowance is returned zero even after approval

I was unit testing my contract and within the tests i approved that the smart contract should be able to spend the tokens of the msg.sender (the owner) and then tried to transferFrom function to transfer the tokens from the msg.sender to the…
1
vote
1 answer

How to send tokens to smart contract call?

I want to make users pay with tokens instead of 'eth'. Smart contract: contract Test { IERC20 token; constructor(address tokenAddress){ token = IERC20(tokenAddress) } function payWithToken() external { …
1
vote
0 answers

Flashloan on Aurora. but get "A status code indicating if the top-level call succeeded or failed (applicable for Post BYZANTIUM blocks only)

I am had successfully deploy a flashloan contract on both Aurora & Aurora+ network (an EVM on Near protocol). and also successfully tested with its RPC on hardhat, there are no issues, able to borrow and return fund. However, when execute on…
ck lai
  • 11
  • 2
1
vote
1 answer

cannot approve contract to ERC-20 token due to ProviderError: HttpProviderError error

OracleSwap is a DEX that is a fork of Uniswap. The end goal is I am trying to add liquidity https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-01#addliquidity In order to do this, first we need to approve the OracleSwapRouter…
sungazerr
  • 45
  • 5
1
vote
1 answer

Unreachable code after an inherited function call in Solidity

Compiling the code contract Bar { function blockingFunction() public pure returns (bool) { assembly { return(0,0x20) } } } contract Foo is Bar { function foo() public pure returns(bool) { bool…
kuco 23
  • 786
  • 5
  • 18
1
vote
0 answers

Transaction pending for hours on Goerli testnet

I am doing an Nft Marketplace contract and was trying to run npx hardhat run scripts/mint-and-list.js --network goerli to mint the NFT that was already being deployed on IPFS. However, I have a pending transaction whereby it cannot pass through the…
Mei Kei
  • 23
  • 3
1
vote
2 answers

Web3 python crypto cypher issue on M1 Mac

When I try to build a blockchain transaction using Web3 on python, I'm getting an error that is apparently because I'm using an Apple Silicon computer (2020 M1 MacBook Pro). I'm following a popular Solidity, Blockchain, and Smart Contract course on…
Leon KC
  • 31
  • 9
1
vote
0 answers

If in reflection tokens everyone’s balance in a formula, then how is it deducted when the tokens are transferred

In reference to what another user told me Simplified example User A buys 10 tokens. Current Reflection multiplier = 1.0 getBalance(user A) equals 10 * 1.0 = 10 Something happens which increases the reflection multiplier to 1.1 getBalance(user…
Abdul
  • 11
  • 2
1
vote
1 answer

How to call functions of a contract deployed on hardhat forking mainnet

I am trying to use my own contract's functions deployed to hardhat forking mainnet. To do that I have some steps like this: I added the forking configuration in hardhat.config.js networks: { hardhat: { forking: { url:…
1
vote
1 answer

TypeError: Return argument type tuple(int_const 23,bool,uint8[3] memory) is not convertible to expected type tuple(uint256,bool,uint256[3] memory)

//When I compile and deploy below code. It gives me no error // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MultipleValues{ function returnValues() public pure returns (uint, bool, uint8[3] memory) { return (23, true,…
1
vote
1 answer

Error during initialization of subgraph using Graph protocol

I have a question here regarding The Graph indexing protocol. I am trying to initialize a subgraph but keep getting the error below. My npm version is 9.1.2, yarn version is 3.2.3, node version is 18.12.1, and graph version is 0.36.1. √ Fetching…
Mei Kei
  • 23
  • 3