Questions tagged [interfaces]

The tag has no usage guidance.

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

Solidity cast address to a different class

What's the expected behavior if I cast an address A to a wrong class CA? For example, BAYC (https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#code) is an IERC721Enumerable. What ...
user avatar
0 votes
1 answer
13 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()?
user avatar
0 votes
0 answers
25 views

Interface overriding giving error. Overriding public state variable return types differ

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 ...
user avatar
0 votes
1 answer
15 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 ...
user avatar
0 votes
1 answer
23 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 ...
user avatar
0 votes
1 answer
14 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 ...
user avatar
  • 925
0 votes
0 answers
23 views

Unable to understand solidity code

I was confused how this smart contract is sending requested loan amount back to this smart contract again by calling flashLoan. Reference this challange of Damn VUlnerable HERE // SPDX-License-...
user avatar
0 votes
0 answers
68 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. ...
user avatar
0 votes
0 answers
18 views

Parameters not sent to contract from interface

I have 3 contracts: Contract A that is erc721 COntract B that is a contract a factory Conntract c that is like a marketplace // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./...
user avatar
0 votes
1 answer
26 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 ...
user avatar
0 votes
0 answers
10 views

How to connect my contract to a token on the BSC? Getting "transaction has been reverted to the initial state" VM error

I am trying to create a contract on Remix that connects to a BEP-20 token (already on BSC) and access its functions to query name() and balanceOf(). // SPDX-License-Identifier: MIT pragma solidity ^0....
user avatar
1 vote
1 answer
17 views

Access contract using instance vs Interface

Assume I have deployed ContractA and want to call the function updateX. I can use create an instance of the ContractA or I can use an interface. When you use which one? Both updateXFromB and ...
user avatar
0 votes
1 answer
120 views

How to override an interface function that returns a struct with a mapping

I have an interface with a public function foo that consumes a single address parameter and returns a Point struct: //SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IFoo { struct ...
user avatar
0 votes
0 answers
14 views

How should I write tx to swap ETH for sETH in curve pool?

I try to write script to swap ETH/sETH. but the result is always revert. const amountIn = new hre.ethers.utils.parseEther("1"); const amountMin = await curveContract.get_dy(0, 1, amountIn); ...
user avatar
  • 1
0 votes
1 answer
73 views

new variable types: interface vs contract

Suppose a contract C inherits an interface I. What is the difference between I c; and C c;? For instance, in both cases C c = new C() and I c = new C()it seems c points to a newly deployed instance of ...
user avatar
0 votes
1 answer
49 views

What does passing msg.sender to an interface do?

I was doing Ethernaut's Elevator problem when I noticed the code below: // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface Building { function isLastFloor(uint) external returns (...
user avatar
1 vote
1 answer
83 views

What is the difference between ERC20.transferFrom and IERC20.transferFrom?

Calling ether of these in my contract does the same thing. What is the difference then? ERC20(tokenAddress).transferFrom(msg.sender, address(this), amount); IERC20(tokenAddress).transferFrom(msg....
user avatar
  • 387
0 votes
0 answers
28 views

Writing local interfaces for external contracts

I have come across a number of contracts/repos where local interfaces have been written in order to interact with external contracts. For example this simple contract which defines interfaces in /...
user avatar
  • 111
0 votes
0 answers
19 views

Can not get a kitty from cryptokitties contract with id

When I am calling the getKitty function with a random id that I got from website, it is giving me an error. This is the code: interface KittyInterface{ function getKitty(uint256 _id) ...
user avatar
1 vote
1 answer
87 views

Why can't I Transfer ERC20 Tokens through my ERC721 contract as payment?

Here's the function: function transferERC20() external { _erc20.transferFrom(msg.sender, erc20Recipient, 6*10**18); } After I imported the IERC20 Interface to interact with ERC20 tokens ...
user avatar
  • 15
0 votes
1 answer
52 views

Can I take a mapping from one contract, and access it with an interface from anther contract?

Lets say I have a mapping in contract A, which is already deployed.. Can I use an interface in contract B to access the mapping (and the values it links)? If not, is there any way to do this?
user avatar
  • 11
0 votes
0 answers
16 views

Question about a struct called in an interface

a huge thanks to the members here for their support. I have a question regarding a struct that is declared in an interface. Lets say you have two contracts: "Contract_A", which is already ...
user avatar
  • 11
0 votes
0 answers
42 views

How to instantiate functions of other smart contracts to write and read data from the same contract on Solidity?

I'm trying to understand inheritance, interfaces and the call of functions from other smart contracts in Solidity. So I did this example; there is a MyInterface interface in which is declare a struct ...
user avatar
  • 1
1 vote
0 answers
94 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 ...
user avatar
  • 13
0 votes
1 answer
97 views

How do interfaces return values?

I'm looking at the function below and they access the balance of the contract through an interface, but interface functions don't have functionality so how is it returning a value? And the function ...
user avatar
0 votes
1 answer
132 views

supportsInterface breaking viewability on OpenSea

I have two identical ERC721 contracts that allow for minting nfts with one exception. One of the contracts has the following bit of code: function supportsInterface(bytes4 interfaceId) public view ...
user avatar
0 votes
1 answer
162 views

Solidity: Pass a custom interface as argument in a function which changes

I am writing a smart contract as follow: contract MyContract { function doSomething(address newAddress, interface newInterface) { _newAddress = newInterface(newAddress); _newAddress....
user avatar
0 votes
1 answer
190 views

AttributeError - 'InterfaceContainer' object has no attribute

from brownie import config, network, interface from scripts.helpful_scripts import get_account from scripts.get_weth import get_weth def main(): account = get_account() erc20_address = config[...
user avatar
0 votes
0 answers
88 views

Gas cost of mapping lookup and update inside mint transaction compared to getting a variable and then interfacing with another contract function

I have a mint function that does a lookup in a mapping to get some data and then after some computation updates that keys value, and mints. For the specific use case, i've identified an option of ...
user avatar
0 votes
0 answers
11 views

Interface validation

I want to share my pain, guys 🙂 I learn Solidity and found that there are no normal interface validations. I am not sure of how to really interact with external contracts without importing them ...
user avatar
1 vote
2 answers
407 views

How to check If the smart contract support an interface?

I have token contract which implements IERC2981 interface and I've overridden the supportsInterface function like so. function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721,...
user avatar
  • 155
0 votes
1 answer
468 views

How to get contract address when receiving an ERC-721 token in a contract?

I'm writing an NFT staking contract and I want my contract to accept NFTs only from 3 specific contracts. I have implemented IERC721Receiver and the onERC721Received function successfully fires. What ...
user avatar
0 votes
0 answers
12 views

So, anyone can access any smart contract just by using interfaces right? [duplicate]

If true, how can I restrict access to my future contracts to only me?
user avatar
  • 15
0 votes
1 answer
70 views

solidity interface - Contracts calling unimplemented functions

I'm new to solidity and OOP. I'm trying to understand the code in this simple lottery game example: https://github.com/alphachainio/chainlink-lottery/blob/master/ethereum/contracts/ I am confused when ...
user avatar
  • 62
0 votes
1 answer
47 views

How do I find the code of a external interface function?

I am learning about importing contracts and noticed with the following contract there is an external interface function with no code block. Where does this code come from? function version() external ...
user avatar
  • 103
0 votes
1 answer
303 views

How to declare getter function signature in interface for a mapping?

I have a contract that implements an interface, the contract has a state variable mapping(address => bytes32[]) public usersLists, I defined a getter function signature in the interface for this ...
user avatar
  • 230
0 votes
0 answers
60 views

How to use vyper's external_interface in brownie?

An external interface can be generated by vyper as such: vyper -f external_interface contracts/CurveCryptoSwap.vy Doing that results in the following output: # External Interfaces interface ...
user avatar
0 votes
1 answer
49 views

How is an interface initialised?

// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; pragma abicoder v2; import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import '@uniswap/v3-periphery/contracts/...
user avatar
  • 159
0 votes
0 answers
40 views

calling functions from deployed library

Suppose I have the follow Library deployed at Address A library aLibrary { address constant owner = //AddressB; function customSend(uint256 value, address receiver) public returns (bool) { ...
user avatar
  • 121
1 vote
1 answer
685 views

How to access a public state variable from another smart contract through an interface in Solidity

I have a newbie question about accessing a public variable in another contract which was deployed. Contract Escrow needs to get value from another contract DoubleTrade deployed at an address. Here is ...
user avatar
2 votes
1 answer
1k views

How to override supportsInterface() function if contract needs to support many interfaces?

I'm creating a basic ERC721 token that extends ERC721, ERC721Enumerable, AccessControlEnumerable. I want it to support ERC721Enumerable and AccessControlEnumerable interfaces. Is it enough to call ...
user avatar
  • 122
0 votes
1 answer
28 views

What contract does an interface points to?

I keep reviewing code with interfaces, without seeing any reference anywhere of what contract that interface points to. For example in this contract for the popular cryptocurrency Axie Infinity: ...
user avatar
1 vote
0 answers
317 views

Using imported solidity interfaces with brownie

It seems like brownie compile doesn't produce ABI for an imported interface. I would like to use OpenZeppelin IERC20 interface. Here is the setup: brownie-config.yaml: dependencies: - OpenZeppelin/...
user avatar
  • 11
0 votes
0 answers
42 views

Defining vs Casting an Interface

When reviewing smart contracts, I often see the interfaces of other contracts in the same file, however I never understood how that specific contract knows which contract that interface is referencing....
user avatar
1 vote
2 answers
167 views

interacting with an enum as an interface in other contract

having this issue of using enum as interface in other contract: will appreciate your help... // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; interface interEnum { enum SIDE { ...
user avatar
0 votes
1 answer
811 views

How do Interfaces in Solidity know which contract they are interfacing?

To my understanding, an address at some point needs to be provided so that the name of the interface that you write in your code is linked to the existing external contract you want to interface with. ...
user avatar
1 vote
1 answer
363 views

How to interact with Ethernaut contracts via Remix

I'm going through the Ethernaut levels and I have some fundamental questions I need answered before I can continue. This question is particularly in reference to the levels that require you to deploy ...
user avatar
  • 11
1 vote
2 answers
748 views

Is there a way to get an interface ID of a Solidity interface using ethersjs?

Is there a way to get an interface ID of a Solidity interface using ethersjs? I'm using ethersjs in my test file and I want to test if the supportsInterface is returning a correct interface ID. I ...
user avatar
  • 255
0 votes
1 answer
550 views

What's the interfaceID for ERC-20?

What's the interfaceID for ERC-20? It's not in the EIP. It's shown for 165 and 721 but not for ERC-20.
user avatar
  • 111
0 votes
0 answers
14 views

What happens if there a different interface is passed into a function in solidity?

Given a deployed contract with a method that has an interface for ERC20 interface IERC20 { function totalSupply() external view returns (uint256); } contract SomePublicContract { function ...
user avatar