web3j icon indicating copy to clipboard operation
web3j copied to clipboard

How to deploy erc721 use web3j??

Open unqjohnny opened this issue 2 years ago • 1 comments

I have origin bin file and wrapper class avaliable, but have some problems when deploy contract. function example:

    public static RemoteCall<GameItem> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(GameItem.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    public static <T extends Contract> RemoteCall<T> deployRemoteCall(Class<T> type, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String binary, String encodedConstructor) {
        return deployRemoteCall(type, web3j, credentials, gasPrice, gasLimit, binary, encodedConstructor, BigInteger.ZERO);
    }

my problem is: how to generate the encodedConstructor??

my sol code like this:

// contracts/GameItem.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract GameItem is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() public ERC721("GameItem", "ITM") {}

    function awardItem(address player, string memory tokenURI)
        public
        returns (uint256)
    {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

unqjohnny avatar Apr 28 '22 08:04 unqjohnny

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 13 '22 05:06 stale[bot]

@unqjohnny please take a look at this tutorial here: https://docs.web3j.io/4.8.7/getting_started/deploy_interact_smart_contracts/

mohamedelshami avatar Oct 21 '22 19:10 mohamedelshami