Questions tagged [function]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
4 views

Unexpected overflow result from a function when inputting max uint256

I am looking at the following function tickUpper that is supposed to retrieve the 24 bits of a 256 bit number beginning at bit 208. It's cast to an int24 because it interfaces with uniswap ticks. I ...
user127148's user avatar
0 votes
0 answers
7 views

Why are these functions using %128?

I am looking at the following functions which (i) take a 7-bit number (up to 127) and add it to 256-bit number, starting 64 positions in from the right and (ii) read that 7-bit number given the 256-...
user127148's user avatar
1 vote
0 answers
10 views

How is this legal? _merkleProof.verifyCalldata(root, leaf)

Code: https://www.contractreader.io/contract/mainnet/0x0C7D4bdA40CF78F9F1BAf6e3D5774f1E22c9CC4B My question is about this verifyCalldata() call: function verifyAddress( uint256 _projectId, ...
Donn Lee's user avatar
  • 111
0 votes
0 answers
21 views

how to get a function's signature that have a structre as parametter

function createClone( uint256 dbId, launchpadLib.IDOInfo memory _idoInfo, launchpadLib.IDOInfoTwo memory _IDOInfoTwo ) external{} I have this funtion how can i make signature of this function with ...
VIKASH VASHISHAT's user avatar
1 vote
0 answers
9 views

Attack vector in direct transfer function in EC721

How the attack vector would look like in case of direct transfer function in EC721 standard. It is described in the comment A marketplace is transferring an NFT from Bob to Mary (among many other &...
ramiz_karaeski's user avatar
2 votes
2 answers
110 views

What is an Internal function type variable?

I was going through solidity documentation and found this paragraph inside "Function Types" section https://docs.soliditylang.org/en/v0.8.21/types.html#user-defined-value-types A function of ...
ImBatman's user avatar
2 votes
1 answer
53 views

Possible way to hack Solidity into executing a function directly from a struct as a method? (v0.8.20)

pragma solidity 0.8.20; contract SolidityLimitTest { mapping (address => Hack) private Hackable; struct Hack { uint amount; function(uint) returns (uint) ten_x; } ...
Ashraile's user avatar
0 votes
1 answer
41 views

What is the correlation between "Hash" (Method ID) & "Name"

I was checking Etherscan and come across a deployed contract (Create contract), but the method id was 0x60a06040. I then used https://openchain.xyz/signatures?query=0x60a06040 and found out that the ...
anon's user avatar
  • 25
0 votes
1 answer
10 views

Do you have to explicitly state in the body of a function that it should return something?

I'm looking at the following function which is supposed to return (uint8 id, uint8 nextId). I see that in the body of the function, the return statement is within an "else" statement - see ...
auditor_chick's user avatar
0 votes
1 answer
13 views

Creating a local variable in an if statement?

I'm looking at a function that creates a local variable in an if statement. If someone called that function and the condition to the if statement was not triggered, that local variable wouldn't exist, ...
auditor_chick's user avatar
2 votes
1 answer
74 views

Where in the code of this unstake function is ETH actually transferred?

I am looking at this repo, which is contracts for a decentralized pegged asset issuance system backed by liquid staking tokens like rETH. Specifically, I have a question about the functions unstake in ...
auditor_chick's user avatar
0 votes
1 answer
18 views

Can you refer to a contract inside itself?

Sorry this is a very minor question but the following is part of a contract called LibOrders.sol. The function below calls LibOrders.cancelOrder....normally I think you would just put "...
auditor_chick's user avatar
1 vote
1 answer
57 views

Two people calling this function at exactly the same time

I was looking at Rocket Pool's docs on interacting with other contracts and they included a simple example function that another protocol could use to accept deposits of ETH, forward it to RP, and get ...
auditor_chick's user avatar
1 vote
1 answer
16 views

Can you return something only some of the time with a function in solidity?

I am looking at a function that says it returns two uints, but the return statement is inside an else statement, so obviously there are conditions under which nothing would be returned. Can you have ...
auditor_chick's user avatar
1 vote
1 answer
25 views

How can I execute a call from a contract using another contract?

I own a contract (contract A), which in turn, when deployed, created a secondary contract (Contract B). I have funds trapped in contract B, contract B, has a function that allows its owner to withdraw ...
Leandro Loures's user avatar
0 votes
1 answer
16 views

Revert inside a for loop

If there is a revert inside a for loop that is inside a function, and the revert is triggered, will the whole function revert?
auditor_chick's user avatar
2 votes
1 answer
29 views

Invoking a function with different amount of input than the function takes

function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b,...
Harsh Dhankhar's user avatar
1 vote
1 answer
18 views

When calling a custom function on an ERC721 it keeps reverting when called from the frontEnd but works if called from remix

I am having an issue calling a function on one of my contracts. I have an ERC721 contract that has a function getTokenUnlockableContent. function getTokenUnlockableContent( uint256 tokenId ) ...
Tebbo's user avatar
  • 11
0 votes
1 answer
230 views

How Can I Filter Ethereum Transactions by Method ID or Name, Similar to Etherscan's Advanced Filter Feature

I am working on a project where I need to retrieve all transactions associated with a specific method within a given block or set of blocks. As an example, Etherscan provides this functionality ...
Daniel Kotlarov's user avatar
1 vote
2 answers
49 views

how does swapExactTokensForETHSupportingFeeOnTransferTokens work and its inputs

I tried many things on inputs but unfortunately I am just receving a gas error (the one that says would likely fail if continued) How does the function input works exactly? uniswapV2Router....
Lupus7's user avatar
  • 11
0 votes
0 answers
114 views

TypeError: AbiCoder is not a constructor, testing purchaseSnack function is failing. I think due to not handling ether conversion correctly

I am trying to write a test script using hardhat to test the purchaseSnack function but I keep receiving these errors. 1) VendingMachine Should fail if insufficient funds are sent: ...
Daryle's user avatar
  • 1
0 votes
1 answer
52 views

How can I modify this function to return my wallet address?

How do I modify this function to return my wallet address using uint160? I want to remove all the for-loop logic. I've created this contract and sent ETH to it, but I am having trouble getting the ETH ...
user3705373's user avatar
0 votes
1 answer
12 views

Function with both override and virtual keywords

What I understood from this is that if a function has virtual keyword, it can be overridden. And if a function has the keyword override means it is overriding another function. So, does the function ...
ratib90486's user avatar
0 votes
1 answer
14 views

Hello. Is token mint allowed in this snippet? Or can it be mint again?

function mint(address user, uint256 value) external onlyOwner { require(user == OWNER, "NOT_OWNER"); balances[user] = balances[user].add(value); totalSupply = totalSupply.add(value); ...
Azimov Zaur's user avatar
0 votes
2 answers
103 views

Calling Aave Lending Pool V2 "Borrow" function returns "reverted with reason string 59"

My smart contract is trying to use stETH as collateral to borrow 250 WETH on the Aave Lending Pool V2, but the borrow function reverts with code 59: BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows ...
MasterShake20's user avatar
0 votes
1 answer
35 views

Call contract's function

I'm new in solidity and blockchain itself. Typed myself contract for Voting in VSCode and tried to figure out how I can run code and research workflow and etc. During researching figured out that for ...
gaandalf's user avatar
0 votes
1 answer
23 views

How to use another deployed smart contract functions?

What I want to do is deploy a smart contract with functions that other deployed smart contracts can call and get a response from. How do I implement this? Is there any useful guides you guys know I ...
Mohd Arafat Hossain's user avatar
0 votes
1 answer
69 views

Chainlink Functions return an array or list of strings from Functions-request-source.js

Hope someone can help. I am stuck trying to work out how best to extract the different string values from the returned bytes data. Chainlink Function request source requires the return value to be a ...
Vince Reid's user avatar
0 votes
2 answers
31 views

How do you use `delete` on a function?

"If a function type variable is not initialised, calling it results in a failed assertion. The same happens if you call a function after using delete on it." is a quote from the official ...
Iaroslav's user avatar
  • 279
0 votes
0 answers
20 views

does empty function has security risks?

I have to implement the following interface in my contract interface IMetadataRenderer { function tokenURI(uint256) external view returns (string memory); function contractURI() external view ...
sciNFTist.eth's user avatar
0 votes
1 answer
24 views

ParserError in solidity

I wrote the following contract (for educational purposes): // SPDX-License-Identifier: MIT pragma solidity 0.8.8; contract Coin{ holders[] public investors; mapping(address=>...
Fawzy Hegab's user avatar
1 vote
1 answer
42 views

How I do I calculate the price of a Token as the amount of the token bought increases

Let say I created a Min price = 0.00056 ether for 150 coins which is the Min amount and the Max price = 0.1 for 20,000 coins which is the Max amount. What will be the price of the coin when I buy 1000 ...
jacobs david's user avatar
2 votes
1 answer
21 views

SOLIDITY NOOB QUESTION. Is it necessary to specify that a function is a view function if it's obviously a view function?

For example: function contains(address _key) public view returns (bool) { return map[_key] != 0; } I don't know how this could be manipulated to change the state of anything, so to me it ...
Paul DeLucia's user avatar
8 votes
3 answers
265 views

The redundant `_from` parameter in the `transferFrom` function of an ERC721

The Non-Fungible Token Standard (described in EIP-721) specifies, among other things, the signature of the transferFrom() function: function transferFrom(address _from, address _to, uint256 _tokenId) ...
Iaroslav's user avatar
  • 279
1 vote
1 answer
27 views

Is there a decentralized version of Cloudflare Workers?

Is there a decentralized version of Cloudflare Workers or some comparable service like AWS Lambda functions or GCP Cloud Functions? I would love a blockchain based, or just a decentralized version of ...
ChristianOConnor's user avatar
0 votes
0 answers
10 views

Fuction type assined as as variable to another func name

So, here is a code snippet: function stake ( AssetType _assetType, uint256 _timelockId, uint256, uint256, uint256 ) external nonReentrant { ...
Vlad Zaev's user avatar
1 vote
1 answer
45 views

What is Solidity's equivalent of raw_call()?

I'm wondering, does Solidity also have a raw_call() function like Vyper which sends a byte[] array (payload) as calldata to a specific address? If so, what is that function? Is it also raw_call()?
MuellerSachs's user avatar
0 votes
1 answer
71 views

Function isn't returning the uint256 value after initializing mapping

I'm facing a problem with the function return type in solidity. Here is my code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract Birth { mapping(uint256 => bool) public ...
Asir Shahriar Roudra's user avatar
0 votes
1 answer
60 views

Modifier vs function call

What is more gas efficient and secure, using a modifier(for example only owner) or calling a function to verify state(calling a function that returns owner address and compares that to the address ...
NFT_king's user avatar
0 votes
1 answer
107 views

Error When Passing Struct as Input to Function in Solidity

I'm trying to just call a function that has a struct argument...The thing is that Remix somehow doesn't recognize all the inputs from the struct in the function. I tried making the image very ...
caiosa's user avatar
  • 23
0 votes
1 answer
14 views

Function override error and abstract error after importing the contract

*this a contract for erc721: contract erc721{ event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); event Approval(address indexed _owner,address indexed _approved, ...
Baby's user avatar
  • 29
1 vote
1 answer
19 views

Declaration error: undeclared identifier error in remix while using exiting Owner contract's function getOwner. Kindly help in solving

function withdraw() external isOwner() { address payable owner = address(uint160(getOwner()));//**this is the line I get err owner.transfer(address(this).balance); } owner contract: function ...
Baby's user avatar
  • 29
4 votes
1 answer
34 views

Is it possible to use interface functions as types?

I would like to use a function defined in an interface as a function type, like this: pragma solidity >=0.8.17; interface Foo { function myFunction() external; } contract Contract { ...
Paul Razvan Berg's user avatar
1 vote
1 answer
69 views

Getting two different booleans calling a function 2 times in a row

I tried to create a function which could return me 2 different booleans after I call it two times in a row. I tried my best to use different random methods like storing block.timestamp in an uint, or ...
Vagner's user avatar
  • 21
1 vote
0 answers
36 views

How to identify where coin/token value is changed

I'd like to build an algorithm that analyzes value creation, transfer and destruction on a blockchain (such as new ETH minted, ETH gas burned, ERC-20 tokens transferred, etc.). Assuming I have a ...
Michael C's user avatar
1 vote
1 answer
104 views

Does it make any sense to specify reference type function input parameters as calldata if the given function is only called contract to contract?

As far as I am aware contract to contract calls store input arguments in memory. Or put more precisely they store them in memory and they can be accessed with CALLDATALOAD within the the new call ...
FreddyC's user avatar
  • 181
1 vote
1 answer
18 views

What are the advantages/disatvantages to specify a struct param in a function as calldata vs. memory?

If I am not modifying the input parameter in the function body are there any reasons a reference type parameter should be labeled as stored in memory? More generally what are the reasons to go for ...
FreddyC's user avatar
  • 181
0 votes
1 answer
37 views

Do i need to fund my contracts with eth

I have a protocol composed of multiple contracts which interact with each other, when a user call a transaction in one of the contracts, the contract calls other contracts functions . The question is :...
noro meb's user avatar
  • 328
0 votes
1 answer
62 views

contract recursive dependency

i have two contracts the first one has a function which must be called only by the second contract : contract A { address contractBAddress; uint256 number; modifier onlyB() { ...
noro meb's user avatar
  • 328
0 votes
1 answer
70 views

Why isn't calldata used in this function's argument? (OpenZeppelin/OwnableUpgradeable.sol)

Solidity noob here; reading about data locations i've learned that whenever you don't need to store or modify a function's input value it's actually more gas efficient to set its location to calldata (...
user113310's user avatar