I want to import a deployed smart contract TetherToken and use its functions.

Solidity version of deployed contract TetherToken is:

pragma solidity ^0.4.17;

I want to use its functions in my own contract:

pragma solidity ^0.6.1;
import "TetherToken.sol";
contract L {
    address payable TetherAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    TetherToken Tether = TetherToken(TetherAddress);

But Remix says:

TetherToken.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.7+commit.b8d736ae.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.4.17; ^----------------------^

It's important for me to use features of Solidty 0.6.x, and TetherToken also cannot be compiled by newer version of Solidity.

How can I solve the problem?

P.N: Can I use ABI Code of TetherToken instead of its source?

  • 1
    You don't need to import it, just declare contract TetherToken {...} and include inside it the declaration of whatever functions you're planning to call. – goodvibration Jun 23 at 9:46
  • @goodvibration , Do you mean that no data is needed in used contract and only method interfaces is enough? What about modifiers and events? – Alireza Zojaji Jun 23 at 12:05
  • The contract is already deployed at 0xdAC17F958D2ee523a2206206994597C13D831ec7, right? So all the implementation details are already "there" (on the blockchain). If you extend your question to show exactly which TetherToken functions you are calling, then I might be able to guide you with more specific details on what exactly you need to add in your code. – goodvibration Jun 23 at 12:12
  • I use only transfer() function from TetherToken, But as I know the functions are not saved in the blockchain by their names alphabetically, so how can my contract can access the function by its name? – Alireza Zojaji Jun 23 at 12:29
  • 1
    Doesn't matter, the compiler will translate your TetherToken.transfer function-call to the bytecode required for making this function-call execute correctly. But in order for the compiler to do that, it first wants to know the prototype of this function (i.e., its name, input argument types and return-value type). So you need to declare that prototype, but you don't need to implement the actual function. – goodvibration Jun 23 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.