Questions tagged [function]
The function tag has no usage guidance.
42
questions
0
votes
0
answers
6
views
Help with cycle function in Ethereum Blockchain
I am trying to understand the use of a particular function:
cycle(uint256 vaultId, uint256[] _desiredIds, uint256 maxIterations, bool acceptAny)
What is the purpose of this function? Why is called? I ...
0
votes
1
answer
13
views
Create contract with contract
I want to create a contract that can create contract itself
I find something like this
pragma solidity ^0.5.0;
contract DaughterContract {
string public name;
uint public age;
constructor(
...
0
votes
0
answers
30
views
How to reset all addresses in a mapping assigned a uint256 counter
apologies if I'm not using the correct language to describe what I am trying to accomplish. I'm looking for a solution to reset the "idcounter" to 0 across all addresses, so that they can ...
0
votes
0
answers
22
views
Pure function that reads from storage, compiler bug?
I just came across this while testing around with the Diamond Storage pattern. Here is a 'pure' function that reads from storage. This had me wondering, is there actually any difference between pure ...
0
votes
0
answers
32
views
Gas estimation reverts
I am quite new to blockchain programming and am trying to estimate the gas cost of calling a function from a smart contract.
I am using Web3 js and the Kovan network through an Infura node.
What am I ...
0
votes
1
answer
15
views
Passing different data types to uint parameter
I found out, that I can pass different data types (as argument), even if the Solidity method takes only uint data type, why is that possible?
Example:
function test (uint _param) public {
//do smth
...
0
votes
1
answer
27
views
Looking for data in Smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
contract Storage {
struct People {
uint256 personId;
string vorname;
string nachname;
uint256 birthdate;
...
0
votes
1
answer
27
views
Appending an item into an array inside a struct
Working on solidity 8.12, I have two structs, namely singer and event, two arrays one for singers and another for events. I want to write down a function that creates an event, specifying the singer ...
0
votes
1
answer
22
views
How to test the Solidity-By-Example Mapping smart contract in Remix?
I want to test the following code in Remix. But what is the procedure?
What do I put in the input field for the function labeled set?
Mapping.sol
// https://solidity-by-example.org/mapping
// Mapping
/...
1
vote
1
answer
16
views
Different number of parameters between client and contract functions
From this repository: https://github.com/dabit3/polygon-ethereum-nextjs-marketplace
Look at createToken function inside the JavaScript file (pages/create-nft.js):
let listingPrice = await contract....
0
votes
2
answers
16
views
Why and when to user require(bool) on functions
I want to understand when (and why) it's necessary to use this statement :
require(sent, "failed to send ether")
i could just do somethink like this instead:
0
votes
3
answers
34
views
can we call constructor in another function of the same contract in solidity?
can we call constructor in another function of the same contract in solidity ? Curious, Kindly reply asap. Thanks
0
votes
1
answer
34
views
If not in the EVM, where do internal functions execute?
The Ethereum documentation says that internal functions are not executed in the EVM, while external ones are:
If not in the EVM, where are internal functions executed? Does this simply mean that ...
0
votes
1
answer
18
views
if-else in Solidity Doesn't Work
Im creating a web based medicine anticounterfeit using blockchain and this is my smart contact program:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract SupplyChain {
event ...
1
vote
1
answer
18
views
Solhint: Why should I avoid multiple calls of "send" in a single transaction?
function withdrawAll() public payable onlyOwner {
uint256 _each = address(this).balance / 4;
require(payable(t1).send(_each), "Account is being paid out");
require(payable(t2)....
0
votes
0
answers
109
views
Which function calls `AtomicMatch` is called by in opensea source code
I am trying to figure out how to call the function AtomicMatch in opensea. Currently I found it is related to function executeCall (https://github.com/wyvernprotocol/wyvern-v3/blob/master/contracts/...
0
votes
1
answer
28
views
auto generated functions by solidity
send and transfer are automatically generated function to send ether(wei) to some address.
I tried to search a list of such functions in solidity documentation but to no avail, can someone help here? ...
0
votes
0
answers
12
views
When I call a contract's view function. Where does the code run?
Does it get executed on my browser by metamask with data requested from a node? Or does the node runs it?
0
votes
1
answer
26
views
Distinguish between function calls from externally owned accounts, and from another smart contracts
I wanted to know how to distinguish between a function call from an externally owned user account and a function call from another smart contract in solidity. Can anyone help me with this?
0
votes
1
answer
39
views
Does it make a difference using multiple setter functions vs a single generic one?
Let's say I have an enum and set the default:
enum Status {
INACTIVE,
FAIL,
SUCCESS,
PENDING
}
Status public myStatus = Status.INACTIVE;
I'm wondering if one approach to updating ...
0
votes
0
answers
36
views
Remix IDE, Solidity: Function command not showing up inside deployed contract?
Why does the 'withdraw' function not show up in the contract?
Using freecodecamp tutorial on remixIDE
Here is my code....
pragma solidity >=0.6.6 <0.9.0;
import "@chainlink/contracts/src/v0....
0
votes
2
answers
46
views
Can access to base URI allow users to anticipate rare NFT by looking at json files?
I've been looking at some NFT Smart Contract functions and I noticed that there were a function that allows access to the base URI, which can basically be the address where the .json files (including ...
0
votes
0
answers
149
views
Is it possible to decrypt a signed message given public or private key and message's signature?
a smart contract's function requires a certificate input that should be created using a signed message by the relevant wallet which will call that function.
Is it possible to decrypt that signed ...
0
votes
1
answer
19
views
very important interface need help
the balance not change from another contract
pragma solidity ^0.8.10;
interface ICounter {
function balanceOf(address owner) external view returns (uint);
function transfer(address to, uint ...
0
votes
1
answer
18
views
Values added inside of an object that are not parameters of the function
I've seen this in Solidity several times, but I can't find it in the documentation nor do I know how to describe it in a search engine. Say you have a function:
function buyItem(uint256 _upc)
...
1
vote
1
answer
18
views
What does {...} as a part of a function call mean?
In the function swapExactETHForTokens of Uniswap is called like this:
uniswap.swapExactETHForTokens{value: msg.value}(
amountOut,
path,
msg.sender,
...
0
votes
1
answer
137
views
How do I change smart contract state with web3.js?
I am using web3.js to interact with a smart contract. I can read values, but I can't change the state with setting functions in the contract.
contract MyContract {
uint number;
function ...
0
votes
0
answers
10
views
ClaimTo function in smart contract
I want to pick up tokens from smart contralkt. I want the tokens to be transferred to another address immediately. Can I do it through the ClaimTo function, if so, what additional costs will be ...
0
votes
1
answer
247
views
how to add pre-mint function (free mint open to everyone with limit of mint)
I am trying to write a function that would allowed the first 2000 mint are free and then the contract stop until i start the public mint.
it would be be like two public mint, i guess.
thank you in ...
1
vote
0
answers
28
views
What the this keyword means?
im doing the ethernaut course. what does this mean ? I know what for exemple address(this)means, it s the address of the smart contract but like what does it means when the this is alone like this?
1
vote
0
answers
96
views
Best practice for calling function from another contract
I'm a bit of a beginner so I'm sorry if I misphrase anything, but I haven't been able to find a definitive answer on this yet. I'm going through some tutorials which list out a few ways to call ...
0
votes
1
answer
85
views
Perform an internal function from outside the contract
A few weeks ago I read a comment here on the forum with a link to an article that said it was possible to perform a function marked as internal from outside the contract. That is, it is possible ...
0
votes
0
answers
166
views
What is a valid regular expression for a solidity variable or function?
Say I have a function or variable(either one doesn't really matter since functions and variables can have the same names) called foo, how do I test using a regular expression that this function/...
0
votes
1
answer
69
views
Is a function like that possible? (Burn/swap)
Good morning everyone, I’m starting smart contract dev and I have a lot of questions.
But the biggest question I have is I have one idea in head and I don’t know if it’s possible.
To explain:
You have ...
1
vote
1
answer
50
views
Solidity: Restrict access to functions
Today I found a contract on etherscan providing a restriction on one of the two existing "withdraw" methods and I asked myself: If you would call this function withdraw() as not the owner, ...
0
votes
0
answers
13
views
Correct terminology for referring to a specific function of a specific contract
Is there a preferred way of referencing a function of a contract in English?
For example, suppose I want to say to someone "to learn more, call the contractInfo function on the contract with ...
1
vote
1
answer
38
views
When to use memory and when not to use?
I watched this video and he uses memory a lot like function verify(address _signer, string memory _message, bytes memory _sig. Why so? Could the function work without using memory?
While the usual ...
0
votes
1
answer
14
views
Does a double space have an effect inside function declaration?
function doSomething(uint256 _someAmount) external {
I accidentally made a double space between uint256 and _someAmount
Does this make any difference, or is it okay?
Do these 2 lines work the same ...
0
votes
1
answer
36
views
What happens if a function that is not defined as a view, doesn't change the data of the contract?
example:
function addAllowedTokens(address _token) public onlyOwner {
if (!tokenIsAllowed(_token)) {
allowedTokens[_token] = true;
}
}
In this code, the allowedTokens ...
1
vote
1
answer
568
views
Why can't I access the Uniswap v3 Factory .getPool() function?
As a personal exercise, I am trying to convert the following Uniswap v2 project to Uniswap v3:
Uniswap token price monitoring (this is not swapping), i.e. ETH/DAI
https://www.youtube.com/watch?v=...
2
votes
1
answer
43
views
DAO like functionality on Gnosis?
I am a Gnosis newbie. Want to set up a safe for an investor group. It seems like the safe has awesome functionality for that. As the group potentially expands beyond my small circle, may offer ...
2
votes
1
answer
33
views
Is there an EVM compiler that supports coroutines? (e.g. generator functions)
With coroutine I mean a subroutine that can be paused and resumed from another subroutine; preserving its internal state across pauses and resumes.
For example, a feature similar to:
Javascript's ...