How to use third party contract to send ERC token

0 votes

I want to send ERC721 tokens using a third-party contract that I have and I trying to do it with the following code but I know it’s not right. How to do it?

pragma solidity ^0.4.24;



import "../../SuperERC721Token.sol";



contract MyContract {


    SuperERC721Token internal externalToken;


    constructor(address address) public {

        externalToken = SuperERC721Token(address);

    }


    function ThirdPartyTransfer(string hashedTRX) public {

        externalToken.call(hashedTRX); // this function allow the contract to send an ERC721 token to another address

    }

}
Aug 10, 2018 in Blockchain by digger
• 26,740 points
1,045 views

1 answer to this question.

0 votes

You can do it by using a code similar to the example mentioned below:

interface ERC721 /* is ERC165 */ {

    event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

    event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);

    event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

    function balanceOf(address _owner) external view returns (uint256);

    function ownerOf(uint256 _tokenId) external view returns (address);  

    function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;

    function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

    function transferFrom(address _from, address _to, uint256 _tokenId) external payable;

    function approve(address _approved, uint256 _tokenId) external payable;

    function setApprovalForAll(address _operator, bool _approved) external;

    function getApproved(uint256 _tokenId) external view returns (address);

    function isApprovedForAll(address _owner, address _operator) external view returns (bool);

}


interface ERC165 {

    function supportsInterface(bytes4 interfaceID) external view returns (bool);

}


interface ERC721TokenReceiver {

    function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4);

}

And in the contract that you want to call functionA, you add this code:


SuperERC721Token erc721Token= ERC721Token(0x0000000000000000000000000000000000000000); //Replace 0x000000000000000000000000000000000000000 with the address of SuperERC721Token

erc721Token.functionA();
answered Aug 10, 2018 by slayer
• 29,370 points

Related Questions In Blockchain

0 votes
0 answers
0 votes
1 answer

How to swap an Ethereum ERC-20 and Neo NEP5 token with a smart contract?

Each blockchain is its own separated administration. ...READ MORE

answered Apr 12, 2022 in Blockchain by Soham
• 9,710 points
782 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,100 points
3,607 views
+1 vote
1 answer

How to write an ERC 721 contract?

You could go through the following links:  https://github ...READ MORE

answered Jun 28, 2018 in Blockchain by Perry
• 17,100 points
3,153 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,927 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
45,222 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,455 views
0 votes
1 answer

How to store photos in Hyperledger smart contract?

To do this, you need to represent ...READ MORE

answered Jul 9, 2018 in Blockchain by slayer
• 29,370 points
850 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP