Skip to content

Instantly share code, notes, and snippets.

@MrStahlfelge
Last active February 2, 2022 12:59
Show Gist options
  • Save MrStahlfelge/07b3b05212d40ab9ff7aa3a586934714 to your computer and use it in GitHub Desktop.
Save MrStahlfelge/07b3b05212d40ab9ff7aa3a586934714 to your computer and use it in GitHub Desktop.
private ReducedTransaction getReducedSendTx(boolean isMainNet, long amountToSend, Address sender, Address recipient) {
NetworkType networkType = isMainNet ? NetworkType.MAINNET : NetworkType.TESTNET;
return RestApiErgoClient.create(
getDefaultNodeUrl(isMainNet),
networkType,
"",
RestApiErgoClient.getDefaultExplorerUrl(networkType)
).execute(ctx -> {
ErgoTreeContract contract = new ErgoTreeContract(recipient.getErgoAddress().script());
UnsignedTransaction unsignedTransaction = BoxOperations.putToContractTxUnsigned(ctx,
Collections.singletonList(sender),
contract, amountToSend, Collections.emptyList());
return ctx.newProverBuilder().build().reduce(unsignedTransaction, 0);
});
}
public static final String NODE_MAINNET = "http://213.239.193.208:9053/";
public static final String NODE_TESTNET = "http://213.239.193.208:9052/";
private static String getDefaultNodeUrl(boolean mainNet) {
return mainNet ? NODE_MAINNET : NODE_TESTNET;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment