Created
January 31, 2025 04:18
-
-
Save satran004/cd603c1ea2ece0a683f9ded083b90f99 to your computer and use it in GitHub Desktop.
BuilderFestTx with CCL 0.6.3
This file contains hidden or 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
| //CCL 0.6.3 | |
| import com.bloxbean.cardano.client.account.Account; | |
| import com.bloxbean.cardano.client.api.model.Amount; | |
| import com.bloxbean.cardano.client.backend.api.BackendService; | |
| import com.bloxbean.cardano.client.backend.blockfrost.common.Constants; | |
| import com.bloxbean.cardano.client.backend.blockfrost.service.BFBackendService; | |
| import com.bloxbean.cardano.client.common.model.Networks; | |
| import com.bloxbean.cardano.client.function.helper.SignerProviders; | |
| import com.bloxbean.cardano.client.governance.DRepId; | |
| import com.bloxbean.cardano.client.quicktx.QuickTxBuilder; | |
| import com.bloxbean.cardano.client.quicktx.Tx; | |
| import com.bloxbean.cardano.client.transaction.spec.governance.DRepType; | |
| public class BuilderFestTx { | |
| private static String mnemonic = "<your mnemonic>"; | |
| private static Account account = new Account(Networks.mainnet(), mnemonic); | |
| private static BackendService backendService = new BFBackendService(Constants.BLOCKFROST_MAINNET_URL, "<Blockfrost Key>"); | |
| public static void main(String[] args) { | |
| String receiver = "addr1zyzpenlg0vywj7zdh9dzdeggaer94zvckfncv9c3886c36yafhxhu32dys6pvn6wlw8dav6cmp4pmtv7cc3yel9uu0nqhcjd29"; | |
| //Get a Drepid from cexplorer | |
| var drep = DRepId.toDrep("drep1kyppjlhz4lawh4g0ewx2d8a5l20t4yclfnppnuvdkmt7vccg836", DRepType.ADDR_KEYHASH); | |
| //Register your stake address if it's not registered yet. | |
| // Tx tx = new Tx() | |
| // .registerStakeAddress(account.stakeAddress()) | |
| // .from(account.baseAddress()); | |
| Tx tx = new Tx() | |
| .payToAddress(receiver, Amount.ada(150)) | |
| .delegateVotingPowerTo(account.stakeAddress(), drep) | |
| .from(account.baseAddress()); | |
| var result = new QuickTxBuilder(backendService) | |
| .compose(tx) | |
| .withSigner(SignerProviders.signerFrom(account)) | |
| .withSigner(SignerProviders.stakeKeySignerFrom(account)) | |
| .completeAndWait(System.out::println); | |
| System.out.println(result); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment