Questions tagged [interfaces]
The interfaces tag has no usage guidance.
75
questions
6
votes
3answers
8k views
How to call smart contract from html/Javascript
I want to have an html/Javascript code interact with a smart contract. Can someone please outline the basic/high level steps? I am seeing too many things spread across the net, finally confusing.
5
votes
1answer
5k views
Deploying abstract contracts and interfaces
I am trying to create a basic inheritance hierarchy with abstract/virtual formalisms. Consider the following two contracts:
Abstract Contract (IUser.sol):
contract IUser {
function addUser (...
5
votes
1answer
3k views
How to get address of contract interface
In the contract below, how to look up address of tokenContract ?
Operator != not compatible with types address and contract Token
if(msg.sender != tokenContract) throw;
contract ...
4
votes
1answer
1k views
(Sub) contract vs. library vs. struct vs. Interface
First I googled and read through these questions:
Creating multiple contracts or Single contract with struct
Child contract vs struct
Why are so many examples using separated contracts (e.g. crowed ...
3
votes
2answers
523 views
ERC-721 safeTransferFrom is overloaded?
According to ERC-721 interface the function safeTransferFrom seems to be overloaded:
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address ...
3
votes
1answer
905 views
How to interact with ERC20 interface?
My target is to send from the ERC20Wrapper.sol deployed contract BAT tokens to my hard coded address.
I've created ERC20 Interface:
pragma solidity 0.4.18;
interface ERC20 {
function ...
3
votes
2answers
650 views
Can we modify ERC20 functions?
I have to create and transfer token using ERC 20.Inside the standard interface of ERC 20, we have function approve(address spender,using token) which inturn approves spender to take some token from (...
3
votes
1answer
297 views
Ethereum address URL
Is there a standard or a convention for URLs of Ethereum address?
That is I want clicking xxx://0x... to initiate transfer to this account.
3
votes
1answer
1k views
Does a Solidity Interface Contract need to implement all functions, or only the function subset used in the contract that implements the interface?
Let's assume the following:
There is a master contract A, an interface contract IB, and a slave contract B
A implements IB to allow upgrading B without redeploying A
Question:
Does IB need to have ...
3
votes
1answer
560 views
Why public variables aren't able to implement interface functions?
I'm curious why interfaces don't accept public variables as implementations, since public variables have getter functions generated for them.
For example why couldn't the ERC20 balanceOf interface ...
3
votes
1answer
255 views
Best practices for interacting with other contracts
I would like to know what is the best approach and the best practices to intercat with other contracts.
Here are the MyFriendToken.sol and the MyService.sol:
MyFriendToken.sol
I would like to know ...
2
votes
2answers
341 views
Variables in interfaces
Im trying to implement my first interface. But when I try to add a new variable, Remix tell me that can“t add variables in interfaces.
It have sense to set the fixed variables that the extended ...
2
votes
2answers
548 views
Anyone knows what does this contract code mean?
Refer to the link below:
https://github.com/bokkypoobah/Tokens/blob/master/contracts/MyToken.sol
Line 62:
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens,...
2
votes
1answer
108 views
Why standard tokens inherit interface?
I was wondering why most tokens inherit from an ERC20 interface, instead of just implementing all the functions directly. Are there are any problems that arise if the interface functions are just ...
2
votes
2answers
373 views
Interface initiailization
I'm following cryptozombies solidity tutorial.
In lesson 2, chapter 11 it explains how to create an interface for CryptoKitties as follows:
contract KittyInterface {
function getKitty(uint256 _id) ...
2
votes
1answer
582 views
Solidity function overloading and selectors — member not unique
I have the following contract:
pragma solidity ^0.4.17;
contract test{
mapping(bytes4 => bool) internal supportedInterfaces;
uint public a;
function test() public{
supportedInterfaces[...
2
votes
1answer
560 views
How do I check in solidity if interface is supported?
In the new ERC721 documents (erc721.org), the interface says that one of the functions should be:
/**
* @dev Returns `true` if the contract implements `interfaceID` and`interfaceID` ...
2
votes
1answer
238 views
ERC721: Interface ID Registration
Why we need to register Interface ID in ERC721 token. I was just going through the openzeppelin-solidity erc721 code and curious to know that why we need to use this. That interface id register code ...
2
votes
1answer
91 views
How to properly define an interface in Solidity 0.6?
One of the breaking changes of solidity 0.5 was making explicit function visibility mandatory, hence all interface functions must be defined as external today.
In solidity 0.6, there seems to be two ...
2
votes
2answers
697 views
How to create Interface to read Struct in mapping?
There are 2 contracts A and B.
A has a mapping which returns Struct:
mapping (bytes32 => Cup) public cups;
How can we read the cups mapping in contract B?
Following code doesn't work for sure:...
2
votes
2answers
182 views
ERC20 Interfaces overwriting ERC721 functions - Possible to adhere to standard?
Is it possible to have a contract that both generates and manages its own NFT according to the ERC721 Standard, and is able to make calls to outside ERC20 contracts? My contract currently inherits the ...
2
votes
2answers
61 views
Can't override ERC20 Methods
I try to override ERC20 methods ... The doc says it should be possible but I get the error:
CompileError: @openzeppelin/contracts/token/ERC20/ERC20.sol:96:5: TypeError: Trying to override non-virtual ...
2
votes
0answers
39 views
Nested usage of interfaces?
Using solidity ^4.x, it seems I can use an interface as a parameter type in a function from a different interface.
Example:
interface IERC20 {
function transfer() external;
}
import "./IERC20....
2
votes
0answers
168 views
Can I extend the interface of a contract without redeploying it?
The case I'm dealing with is a contract which should serve as a Data Abstraction Layer.
So ideally, it should provide only getter functions and setter functions.
For example, my interface is:
...
1
vote
2answers
36 views
Is it possible to have an optional property or method in an interface?
I currently can't deploy any contract which doesn't adhere 100% to the specified interface(s). Is there a way to mark some properties or methods as optional and, if not, is this a planned feature?
1
vote
1answer
17 views
In interface does the function listed have to be exactly the same as they are in contract?
In solidity 0.7.x, I am creating an interface of contract A in contract B to allow contract B call functions in contract A.
contract A {
function transfer(address recipient, uint256 amount) public ...
1
vote
2answers
175 views
Why are all parameters prepended by an underscore in ERC interfaces? [duplicate]
For instance, both ERC-721 and ERC-725 have underscores(_) before any function parameter.
I understand that normally their goal is to avoid variable overloading. However, what is the rationale for ...
1
vote
1answer
320 views
Smart Contract Design: Escrow/Controller contract
How would I go about creating follow: Escrow/Controller contract A which is capable of accepting ERC20tokens from contract B, and ETH from party C and do a swap when certain conditions are met.
This ...
1
vote
1answer
42 views
What does mutability guarantees mean in erc721
Some functions from ERC-721 interface contain payable modifiers.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
I was wondering why it is payable and found ...
1
vote
1answer
21 views
In case we have an interface written in a seperate .sol file how do we migrate it successfully?
HI consider i have 3 smart contracts A,B,C.
I have a separate file D.sol which is an interface used in all A,B and C.
What would the migration script look like for this project?
1
vote
1answer
151 views
Can abstract contracts in solidity have state variables?
I want to have one deployed contract with my data structure and all data and another separate contract with functions that calls the deployed contract. If i've understood things correctly, one should ...
1
vote
1answer
44 views
Simple but important question: How to get the value of contract's state when using Metamask? [closed]
I'm designing an HTML file (or a user interface: UI) for my smart contract.
let's assume that my contract has a state as follows:
address public owner;// it is set to "...
1
vote
1answer
727 views
What are the benefits of abstract contracts?
I've seen similar questions, but none answer why people use abstract contracts. I come from a non-OOP JavaScript background, so I have some trouble understanding these things.
From the docs:
pragma ...
1
vote
3answers
255 views
How to detect if a contract has a particular function implemented?
I would like to detect if an address has a particular function implemented.
In this case isSafe:
interface ISafe {
function isSafe() public pure returns (bool _true);
// other functions I ...
1
vote
1answer
757 views
Very simply: setProvider is not a function
I have a very simple contract already deployed to the kovan network
I want to create a very simple web3 interface, so I'm following the truffle webpack metacoin example with the following app.js
...
1
vote
1answer
291 views
Does an API standard for price feeds exist?
The ERC 20 defines a standard interface for designing a token contract. Does a similar standard exist for defining feeds that can be called by other contracts?
1
vote
1answer
30 views
How to deploy smart contract so that average user can interact with its public functions?
I sucesfully wrote and deployed smart contract using Remix and Metask to generate hashes used as keys. This contract has few payable public functions that set or get some numbers. After deploying ...
1
vote
1answer
264 views
creating and array using type Big.Int and counting the sum of all integers inside it
Im communicating with a smart contract trying to get the balances from a list of addresses. I then want to get the sum of all balances but I am stuck on actually creating the array to store all the ...
1
vote
0answers
51 views
Enum type in interface function declaration
I understand that you "cannot define enums" in an interface contract; but, in the contract that I am working with, some of the function declarations require an enum type as an input or output ...
1
vote
1answer
542 views
How does the ERC20 tutorial instantiate an unimplemented interface?
I've been going through the official Ethereum token tutorial and I noticed that the provided token code includes the following lines within the approveAndCall function:
tokenRecipient spender = ...
1
vote
1answer
611 views
Array of interfaces of contracts
In an oop language, I could do the following:
I can define an interface Foo with a function F(). I then define two classes Bar1 and Bar2 implementing this interface. I can then create an array of Foo ...
1
vote
0answers
52 views
What's so special about the .call() function?
All that the docs have to say about it is that it "lets the Ethereum network know we're not intending to persist any changes." So I get that it's used when not conducting a transaction.
So, I decided ...
1
vote
0answers
255 views
ipcapi parameter usage
I initialize a node on my private test net passing only the eth interface in the ipcapi parameter expecting that I won't have access in the other interfaces such as admin etc.. However, when I attach ...
0
votes
2answers
47 views
How bad is it to change a function inside ERC721 interface?
I'm creating a NFT and I want the transferFrom function to be payable. In order to do so I need to edit the ERC721 interface and make that function payable also there.
If I do so everything compiles ...
0
votes
2answers
3k views
File import callback not supported import “./IERC20.sol”;
when I try to compile my contract I see errors like this :
DemirelToken.sol
https://eksiup.com/p/4z49413damc3
here's the code :
pragma solidity ^0.5.0;
import "node_modules/openzeppelin-...
0
votes
1answer
279 views
Solidity, how to cast SmartContract type to address
I am currently a bit stuck with my contract, the issue is following:
I define a smartcontract type which is used for another address (aka address is smartcontract that provides the specified interface)...
0
votes
1answer
1k views
Interfaces in solidity
I have one interface like the following:
pragma solidity ^0.4.11;
interface TokenInterface {
function transfer(address recipient, uint amount) external returns(bool);
}
And the implementation in ...
0
votes
1answer
874 views
how to call one contract function into another contract
contract xyz {
mapping(address => bool) Users;
function add(address userAddress) {
require(userAddress != 0x0 && !Users[userAddress]);
Users[...
0
votes
1answer
96 views
Specify full ABI of another contract?
Contract A calls contract B.
Does contract A need to know B's full ABI for its external functions? Or can you just give it the interface for the functions that contract A will call.
0
votes
1answer
34 views
ERC20 Interface
When you make a token, must you have an ERC20 Interface (such as the one below)? What is the purpose of it?
pragma solidity 0.6.6;
/// @notice ERC20 https://eips.ethereum.org/EIPS/eip-20 with ...