Questions tagged [interfaces]
The interfaces tag has no usage guidance.
184
questions
1
vote
0
answers
14
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
22
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
39
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
41
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
46
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
45
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
35
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
159
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
215
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
34
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
50
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
31
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
388
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
59
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
58
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
65
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
82
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
217
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
0
answers
103
views
yul constructor ABI
I am using an interface as my ABI for ethersJs instead of using an hardcoded Interface like the following.
const iface = new Interface([
// Constructor
"constructor(string symbol, string name)...
0
votes
1
answer
186
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
43
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
54
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
66
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
259
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
29
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
48
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 ,...
0
votes
1
answer
568
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
27
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
119
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
150
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
77
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
176
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
26
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
97
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
614
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
327
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
94
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
49
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
105
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
215
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
565
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
359
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
418
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
440
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()?
4
votes
1
answer
669
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 ...
0
votes
1
answer
94
views
Can't access a struct from one contract in another contract through interfaces. Any help?
I am trying to use a struct defined in one contract in another with the ise of interfaces. But my test cases is giving an error,
AssertionError: Expected transaction to be reverted with Amount cannot ...
0
votes
1
answer
168
views
How to mock an instance of an interface?
Having these interfaces
interface IERC20 {
function totalSupply() external view returns (uint);
function balanceOf(address account) external view returns (uint);
function transfer(address ...
0
votes
1
answer
16
views
implementation is in different address
I have a weird situation. Here is the contract address of Compound Comptroller contract.
However, the address above doesn't implement the contract. Actual implementation is in different address. What ...
0
votes
1
answer
323
views
Brownie contract Interface not working on mainnet-fork
I'm following Patric Collins youtube video and trying to deposit wETH in the wETH contract using an interface and working using a fork of mainnet. I am trying to deposit eth in the next contract.
...
0
votes
1
answer
40
views
Smart Contract Architecture for Wide Ecosystem
I am building my first complex project involving a wide variety of applications. This ecosystem involves multiple contracts, from minting various NFT collections, to a fungible token, community ...