Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mint #20

Closed
NickRibbon opened this issue Jun 30, 2022 · 0 comments
Closed

mint #20

NickRibbon opened this issue Jun 30, 2022 · 0 comments

Comments

@NickRibbon
Copy link
Contributor

public boolean mintNFTByAmount(Web3j web3j, String contractAddress, int amount) {
if (web3j == null) return false;
String methodName = "mint";
String fromAddr = emptyAddress;
Function function = new Function(
methodName,
Arrays.asList(new Uint256(amount)),
Arrays.asList(new TypeReference() {
}));

    String data = FunctionEncoder.encode(function);
    Transaction transaction = Transaction.createEthCallTransaction(fromAddr, contractAddress, data);

    EthCall ethCall;
    try {
        ethCall = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).sendAsync().get();
        //List<Type> results = FunctionReturnDecoder.decode(ethCall.getValue(), function.getOutputParameters());
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    return true;
}


/**
 * 调用NFT的Mint方法根据合约有两种
 * Function: mint(address _to, uint256 _mintAmount)
 ***/
public  boolean mintNFTByAmountAndAddress(Web3j web3j, Credentials credentials, String contractAddress, int amount) {
    if (web3j == null) return false;
    if (credentials == null) return false;
    String methodName = "mint";
    String fromAddr = emptyAddress;
    Function function = new Function(
            methodName,
            Arrays.asList(new Address(credentials.getAddress()), new Uint256(amount)),
            Arrays.asList(new TypeReference<Type>() {
            }));

    String data = FunctionEncoder.encode(function);
    Transaction transaction = Transaction.createEthCallTransaction(fromAddr, contractAddress, data);

    EthCall ethCall;
    try {
        ethCall = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).sendAsync().get();
        //List<Type> results = FunctionReturnDecoder.decode(ethCall.getValue(), function.getOutputParameters());
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    return true;
}

have some problem for contract 721

Repository owner locked and limited conversation to collaborators Jun 30, 2022
@jambestwick jambestwick converted this issue into discussion #24 Jun 30, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant