Questions tagged [interfaces]
The interfaces tag has no usage guidance.
189
questions
1
vote
1
answer
275
views
Why do two interfaces have the same ID even if one of them inherits from another interface?
Take a look at this code:
pragma solidity >=0.8.26;
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface IFoo1 is IERC165 {
function ...
1
vote
1
answer
135
views
How to refer to a library in an interface?
The below code is a function of my smart contract. As you can see, its return data refers to a library. VoteLibrary is a library, and VoteCounting is a struct defined within it. Therefore, VoteLibrary....
0
votes
0
answers
11
views
What is the _statsTracker address on some ERC-20 contracts?
I've been finding some ERC-20 contracts having a _statsTracker address, which then gets used like so:
if (_statsTracker != address(0)) {
IStatsTracker(_statsTracker).updateTransferStats(address(...
0
votes
1
answer
33
views
How to send a message from one contract to another using an interface in Solidity?
Context:
I am developing a smart contract system using Solidity that involves two contracts:
HashedTimeLockEther (Main contract)
Messenger (Interface contract)
Objective:
I want the ...
0
votes
2
answers
44
views
Is there a way to test whether an external contract implements (or does not implement) a given interface method?
How would you determine whether a given contract implements a particular interface method without reverting?
interface IRandomMethod {
function getUint() external view returns (uint);
function ...
1
vote
0
answers
21
views
In what ways can abstract contracts or interfaces be used? [duplicate]
I'm currently learning solidity with an udemy course: https://www.udemy.com/course/blockchain-developer/ and the contents of it are also published here: https://ethereum-blockchain-developer.com/000-...
1
vote
0
answers
24
views
What does this function actually do in ERC1820?
I am unable to understand these two functions from the ERC1820 contract and its use. What does it actually do under the hood?
Function 1 :
/// @notice Checks whether the hash is a ERC165 interface (...
1
vote
1
answer
72
views
What is the right way to import a contract type that uses an interface in hardhat?
I have a contract with an interface that I want to test with hardhat
the contract looks like this
interface IGame {
function play(uint guess) external;
}
contract Test {
address private owner;...
1
vote
1
answer
70
views
question about interfaces and inheritance
I am building my own application for an erc1155 dapp but have some questions about interfaces and inheritance. How do you re-declare functionality that you inherit from another contract? Also, how do ...
1
vote
1
answer
47
views
Do interface functions revert on failure?
I was wondering if interface functions automatically revert the whole transaction on failure or not?
Let's say I want to call the sync() function of a liquidityPair, which usually returns no boolean:
...
1
vote
2
answers
139
views
Is it possible to define interface getters for arrays of structs?
Given a state variable defined like this:
struct Segment {
uint256 foo;
uint256 bar;
}
Segment[] public override segments;
Is it possible to define a getter in an interface?
I've tried this ...
1
vote
1
answer
104
views
Why do some developers make their base contract inherit its Interface?
Some protocols and developers inherit the contract's Interface inside of the base contract and then have the interface contain the actual NatSpec, is this simply for human readability/code ...
0
votes
1
answer
58
views
Calling a safeTransferFrom of a contract that implements an ERC721Upgradeable interface
I have a contract A that inherits the following contracts:
contract NftTemplate is
Initializable,
ERC721Upgradeable,
ERC721URIStorageUpgradeable,
AccessControlUpgradeable,
...
0
votes
1
answer
528
views
Best practices for putting structs in interfaces
I have a struct
struct Person {
string firstName;
string lastName;
uint8 age;
uint256 favNumber;
}
I have a function that returns a Person struct from an array
Person[] private ...
0
votes
1
answer
414
views
Transforming Ethereum ABI(JSON) into Human-Readable ABI in Python
I know there is one example to do it: ethersjs implementation
But how to transforming Ethereum ABI into Human-Readable ABI in Python?
0
votes
1
answer
50
views
Solidity Interfaces : VM revert Error
Im implementing a NFT Marketplace. Where I created Two contracts and an Interface. One contract is Tokens.sol and anotherone is MarketPlace.sol In Tokens Contract I Implemented functions like Minting ...
0
votes
1
answer
93
views
How to get how many tokens are left to mint from an ERC721 smart contract that implements a max supply?
I have an ERC721 that implements a public maxSupply value, so I cannot mint more than a certain amount of tokens.
Thanks to the public modifier, this exposes a method I can call to see what the ...
1
vote
0
answers
41
views
How to pass argument with a specific interface into constructor for a sucessfull etherscan verification?
I have an marketplace contract that needs to be verified. It looks like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol&...
2
votes
1
answer
647
views
Why an external call using an interface reverts if an error occurs in the called function, but why it doesn't rever if it was made using the .call()?
I was wondering what happens under the hood when a tx makes an external call using an interface compared to calling the exact same function but using the low-level call() function and the function's ...
0
votes
1
answer
113
views
Difference between storing an address versus a contract instance?
What is the difference between storing an address of a contract and using a interface to interact with it, versus storing the type of the contract itself (i.e. IPriceFeed v. PriceFeed) within the ...
0
votes
2
answers
84
views
Does Interface inherits modifiers?
Lets say i have contract that has couple functions which i want to call them by my other contracts, so i add some modifiers which help to doing this and.
For interacting with my contract i use ...
1
vote
1
answer
110
views
What does a non-existing external function returns?
I added a custom function, customRoyaltyInfo, to Openzeppelin's IERC2981 interface. I need the means to check if a contract that implements this interface IERC2981 support my custom function ...
0
votes
1
answer
130
views
Variable of interface type ? what is the purpose of giving interface name as variable type?
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.6;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract staking{
IERC20 public s_stakingToken;
IERC20 public ...
0
votes
1
answer
419
views
ParserError: Source "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File outside of allowed directories
I'm trying to compile a "FundMe.sol" contract: the issue is that when I try to compile it I keep getting the following Compiler Error:
Brownie v1.19.2 - Python development framework for ...
0
votes
1
answer
245
views
Waiting for contract to receive an ERC721 token
I'm trying to create a smart contract for raffling a NFT between users. Whenever an user tries create a raffle they need to specify the tokenContract which is the contract address of the NFT, and the ...
0
votes
1
answer
62
views
what is return value `uint liquidity` in IUniswapV2Router addLiquidity?
this is from IUniswapV2Router01.sol:
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
...
1
vote
0
answers
77
views
How to import interface from lower level of Solidity?
I'm extending a large codebase with another contract and I need to import an interface. My new contract uses 0.8.9 but the rest of the codebase is in 0.6.12. I'm using Hardhat multi compile to do ...
0
votes
1
answer
86
views
How to make sure that a contract's interface and functionality isn't lost after converting it to byte code?
Since Ethereum contracts are stored on the blockchain as byte code but people will want to understand how to interact with contracts, I wonder if there is enough information stored about contracts on ...
0
votes
1
answer
360
views
How to access the contents of an array in an external contract?
So, there's this contract (which I don't own) with a public variable:
contract challenge {
address[] public winners;
}
I need to know If my address was successfully added to the list, I have tried ...
0
votes
1
answer
31
views
Not being able to get interface to work
I have been trying to get a basic interface working on remix, but havent managed to. Did read a few examples but I must still be making some mistake.
Trying to interact with this contract:
// SPDX-...
1
vote
1
answer
50
views
When declaring an Interface, do i have to declare the mappings of the contract too?
Actually im wondering if in order to use a mapping from a 3d party contract in an other contract, can i devlare the mapping in the interface and use it like Mycontract.mapping() and view/modifiy it ,...
1
vote
1
answer
764
views
Why do we need an Interface or the contract in ethers.getContractAt() function?
As per my understanding, if we want to get or interract with an already deployed contract, we can use this ethers.getContractAt() function.
But since it's already deployed, can't we just give the ...
1
vote
0
answers
31
views
Using interfaces as function parameters in solidity
Is it recommended to use contract interfaces as function parameters in solidity against using address. like...
function doSomething (IERC20 token) external { ... }
rather than
function doSomething (...
0
votes
2
answers
142
views
Why import library inside own contract?
I have noticed, in Uniswap v2 for exemple, that the contract imports its own library.
For exemple, UniswapV2Pair.sol
pragma solidity =0.5.16;
import './interfaces/IUniswapV2Pair.sol';
...
import './...
1
vote
1
answer
178
views
getContract from forked testnet
when I run hardhat on forked testnet and try to run test script that includes
dai = await ethers.getContractAt("IERC20", DAI)
I get this error:
NomicLabsHardhatPluginError: ...
0
votes
1
answer
133
views
What contract is AggregatorV3Interface using?
I understand that you combine an interface (which puts function names and parameter/return types in scope) and a deployed contract address which actually implements these functions. My question is, ...
0
votes
1
answer
234
views
When calling function from another contract via interface, get transaction reverted
I'm searching everywhere and also looking carefully at my simple code. Of course I'm a newbie but have the feelling that everything is fine on my code (pretty simple):
// SPDX-License-Identifier: MIT
...
0
votes
1
answer
30
views
Is it not necessary to use deployed contract for using interface?
I've been practicing Ethernaut Elevator problem. In this code, it just passing msg.sender to Building interface. But, I think that it should be passing deployed contract address of Building to use ...
1
vote
1
answer
123
views
what is the best and efficient way to call functions of an already deployed contract?
if I want to call a function of an already deployed contract for example an ERC20 token which one is the best and efficient way to call it's functions?
using call method
(bool success, bytes memory ...
1
vote
3
answers
840
views
Why do we need interfaces in solidity?
Let's say contractA has a special function. And made an interface that contains the special function without implementation. To use the function in the other contractB, we can use the interface but ...
1
vote
1
answer
391
views
Uncaught (in promise) Error: 'args.method' must be a non-empty string
This is the error I am getting in my console.. I am unable to understand the bug
inpage.js:8 Uncaught (in promise) Error: 'args.method' must be a non-empty string.
at o (inpage.js:8:31826)
at ...
0
votes
1
answer
152
views
How to properly instantiate a Open Z ERC-20 token within a smart contract?
I just want to double check if my below approach is correct.
I've made two ERC 20 compliant tokens (Token A and Token B) as based on OZ standard:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8....
0
votes
1
answer
53
views
How do I create an interface for a contract that has a function parameter type of another contract?
I'm creating an interface for SudoSwap's Router
And the first function requires has a struct parameter
function swapETHForAnyNFTs(
PairSwapAny[] calldata swapList,
......
)...
And ...
2
votes
1
answer
217
views
What is the practical purpose of interface contracts?
I wanted to make sure I understood the purpose of interface contracts. I understand that they are contracts with unimplemented functions, but wanted to make sure I understood all the ways programmers ...
0
votes
1
answer
291
views
A few simple question about using interfaces vs. standard contracts (IERC721 vs. ERC721)
1.)Is it correct to say..... if i import ERC721.sol into my contract then all the ERC721.sol functions are accessible even if i don't list all the functions in the contract? Meaning... i don't ...
0
votes
2
answers
736
views
Solidity interface between two contracts
i am trying to connect two different Smart Contracts. On one hand I have CRUD.sol, which implements CRUD operations in a struct "Data". I have programmed a method readAllData() that returns ...
2
votes
0
answers
430
views
How should supportsInterface be implemented for interfaces with multiple levels of inheritance in ERC165?
When an interface has multiple levels of inheritance, should the supportsInterface in ERC165 checks the entire entire inheritance stack of the interface or just the top-most level?
Here's an example. ...
3
votes
1
answer
487
views
Get interfaceId from interface in ethers js or hardhat
Solidity has this wonderful way to quickly get the interface id from an interface. Suppose I have the interface
interface undernose {
function overmouth() external;
}
then solidity (at least in ...
1
vote
1
answer
579
views
Solidity class inherit an interface but doesn't implement all its function
I have an interface IA and a contract A which inherit IA. Now if there's a function a() in IA, but I don't implement a() in A. Is there a default behavior when calling A.a()?
5
votes
1
answer
924
views
Interface overriding giving error. Overriding public state variable return types differ [duplicate]
I am trying to import interface in it's contract and overriding function. But 1 mapping is giving error.
Error:
Overriding public state variable return types differ.
Interface:
interface ...