Last active
February 2, 2022 12:59
-
-
Save MrStahlfelge/07b3b05212d40ab9ff7aa3a586934714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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