Questions tagged [function-selector]
The function-selector tag has no usage guidance.
15
questions
0
votes
1
answer
18
views
generate function name yielding a specific function selector
Suppose I have a function with arguments (address _to, uint256 number)
The function selector is found using
let signature = "name(address,uint256)";
let selector = Keccack256(signature) ;
I ...
0
votes
0
answers
16
views
What's the best way to check in constructor that dependency contract is the right one?
For simple access management of multiple contracts of the protocol, instead of each contract inherits open-zeppelin accessControl I'm having two contracts: single AccessControlSingleton and abstract ...
0
votes
1
answer
342
views
How to call certain solidity function based on python function parameter
I was wonder if it's possible to call a smart contract function based on a parameter sent to my function caller. From some research I did, i was able to find a function called getattr(). I was ...
1
vote
0
answers
40
views
Is there a way to call a function via a selector from within a contract?
In the case of calling a function with signature foo(uint256) from contract A, I could use this construction in solidity:
address(A).call(abi.encodeWithSignature("foo(uint256)", 100));
// or ...
1
vote
1
answer
522
views
Can you call internal functions of a smart contract using the function selector?
I have the following contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract Selectors {
bool public called;
function callOtherFunc() public {
bytes4 func = ...
0
votes
0
answers
257
views
Constructing hex data payload for contract interaction
I am trying to construct the data payload as described here and quoted below for interacting with a contract:
https://github.com/ethereumbook/ethereumbook/blob/develop/06transactions.asciidoc#...
2
votes
0
answers
46
views
Why EIP-165 consider 0xffffffff value to be invalid id?
EIP-165 aims to provide a way for a contract to communicate whether it has implemented a certain interface or not. The standard defines the interface identifier as the XOR of all function selectors in ...
2
votes
1
answer
339
views
How to load the first 4 bytes from a bytes calldata var?
It is common for calldata to be encoded as bytes calldata when developing contracts in Solidity.
I need to extract the function selector from such a bytes var. What's the best way to load the first 4 ...
1
vote
0
answers
429
views
Function selector computed differently for libraries?
As documented in various places, the function selector is computed as the first four bytes of the keccak256 hash of the function header, which consists of the function name followed by the list of ...
3
votes
1
answer
4k
views
explanation of appending .selector in solidity smart contracts
I'm trying to understand what .selector means when appended to logic wrapped up inside of functions definitions. I've tried to read the section in soliditydocs, but it doesn't seem to answer my ...
0
votes
2
answers
264
views
What is the advantage of the function selector?
I can't understand the advantage of function selector. Following link
What is a function selctor?
uses function selector to invoke a function of another contract but it uses the statements:
...
13
votes
2
answers
5k
views
What is a function selector?
I am reading an article, it says:
To enable deployment on the Ethereum platform, the contract functions
are compiled into EVM bytecode and a piece of code called function
selector is added, ...
3
votes
1
answer
561
views
Function selector of function that takes enum as argument
If a function takes an enum as a parameter
function foo(MyEnum arg1, uint256 arg2) public returns (bool);
how do I properly compute the function selector for that function?
4
votes
1
answer
436
views
Function selector for constructor & fallback function?
According to https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI, function selector is hashed from function name and list of its arguments put inside ().
For example, with function deposit(...
28
votes
4
answers
28k
views
Calling function from deployed contract
I want to know how to instantiate an existing contract deployed on the blockchain using its address.
e.g:
contract A {
function f1()
{}
}
A is deployed on the blockchain, and in contract B I ...