Questions tagged [interfaces]
The interfaces tag has no usage guidance.
156
questions
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 ...
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()?
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 ...
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 ...
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 ...
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 ...
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-...
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.
...
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 "./...
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 ...
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....
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 ...
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 ...
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);
...
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 ...
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 (...
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....
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 /...
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)
...
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 ...
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?
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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[...
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 ...
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 ...
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,...
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 ...
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?
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 ...
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 ...
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 ...
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 ...
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/...
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) {
...
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 ...
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 ...
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:
...
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/...
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....
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 {
...
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. ...
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 ...
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 ...
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.
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 ...