- Tải ERC721 contract tại đây
- 1 Copy toàn bộ thư mục contracts của openzeppelin-contractsvào thư mục contracts của truffles
- 2 Sau khi copy chúng ta sẽ cấu trúc thư mục kiểu này:
 
- Sửa file truffle-config.js thế này:
module.exports = {
    networks: {
        development: {
            host: "localhost",
            port: 8545,
            network_id: "*",
            gas: 0,
            from: "0x3c31b4b9d6c24bad29498f99aaa6914231362c7f"
        }
    },
    compilers: {
        solc: {
            version: "0.8.0" 
        }
    }
};
- Sửa file 1_initial_migration.js thế này:
const ERC721 = artifacts.require("token/ERC721");
module.exports = function (deployer) {
    const collectionName = 'My First Collection';
    const collectionSymbol = 'MFCL';
    
    deployer.deploy(
        ERC721, 
        collectionName, 
        collectionSymbol
    );
};
- Chạy truffle compile
- Chạy trufle migrate
- Sau khi đã deploy contract thành công chúng ta sẽ chạy truffle consolevà gọi thử các lệnh:
let contract = await ERC721.deployed()
contract.name()
contract.symbol()
contract.transfer("0xf6de26f382078d34446b133fd54191fe49c77273", 1000)
contract.balanceOf("0xf6de26f382078d34446b133fd54191fe49c77273")
Kết quả chúng ta sẽ nhận được:
truffle(development)> let contract = await ERC721.deployed() undefined truffle(development)> contract.name() 'My First Collection' truffle(development)> contract.symbol() 'MFCL'
 
         
                 
                                         
                                         
                                         
                                     
                             
                            