+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
S O L I D I T Y
I N T E R F A C E
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
What it is ?
What is interface in
solidity ?
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Interface
Where all the functions does not have implementation (function body)
pragma solidity ^0.4.0;
interface member{
function setName() public returns (string);
function setAge() public returns (uint);
}
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Abstract Contract Vs Interface
Contract become abstract when at
least one of the function in that
contract does not have
implementation.
In interface all the functions does not
have implementation
Abstract Contract Interface
+ 9 1 9 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y
confidential @Tutorials Diary  | www.tutorialsdiary.com
Use of Interface
Another contract can inherit interface and need to implement all of the functions.
pragma solidity ^0.4.0;
interface member{
function setName() public returns (string);
function setAge() public returns(uint);
}
contract teacher is member{
function setName() public returns(string){
return "Mark";
}
function setAge() public returns(uint){
return 32;
}
}

Interface in solidity

  • 1.
    + 9 19 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y S O L I D I T Y I N T E R F A C E
  • 2.
    + 9 19 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com What it is ? What is interface in solidity ?
  • 3.
    + 9 19 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Interface Where all the functions does not have implementation (function body) pragma solidity ^0.4.0; interface member{ function setName() public returns (string); function setAge() public returns (uint); }
  • 4.
    + 9 19 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Abstract Contract Vs Interface Contract become abstract when at least one of the function in that contract does not have implementation. In interface all the functions does not have implementation Abstract Contract Interface
  • 5.
    + 9 19 5 0 1 7 0 7 7 4 1 T U T O R I A L S D I A R Y confidential @Tutorials Diary  | www.tutorialsdiary.com Use of Interface Another contract can inherit interface and need to implement all of the functions. pragma solidity ^0.4.0; interface member{ function setName() public returns (string); function setAge() public returns(uint); } contract teacher is member{ function setName() public returns(string){ return "Mark"; } function setAge() public returns(uint){ return 32; } }