I am trying to find an example of building a simple Tx of ADA in, ADA out type of transaction using sterilization-lib to get cbor and pass it to Wallet.signTx(cbor). developer.cardano.org has a great cli documentation and walkthrough, if only the same could be available for web-based application.
2 Answers
This answer is a little sidetracked, But may be useful for you and others :)
If you are open to integrating your application with Typhon Wallet then its DApp connector is very simple and developer-friendly which does not require you to build a transaction in your application.
Below is a simple payment transaction using Typhon Dapp Connector,
const paymentTransactionResponse = await window.cardano.typhon.paymentTransaction({
outputs: [
{
address:
"addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np",
amount: "6000000",
},
],
});
that's all needed in your application to build a transaction, You can also add tokens, metadata, datum, and minting with this.
More examples, https://docs.typhonwallet.io/examples/paymentTransaction.html#sending-ada
NOTE: Typhon Dapp Connector does not follow CIP-30
-
1Thank you so much for the answer. I will give it a look. But I am trying to use the more general CIP0030 convention in order to build wallet-agnostic dapps. Nami also has simple methods like the one above. These are great solutions for quick fix, however, being wallet-agnostic I guess is a great feature and also assure longevity of the dapp– FourzinCommented Mar 16, 2022 at 8:01
-
I completely agree with your point on dapp needs to be wallet agnostic, but this is not a solution for a quick fix instead this approach is more developer-friendly. Dapp developers job is not to read cardano specs, do UTXO selection, fee calculation and what more, Instead developer should be more focused on building DApp application logic. Commented Mar 16, 2022 at 15:21
There are examples here:
https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions
https://developers.cardano.org/docs/get-started/cardano-serialization-lib/create-react-app
And I have created a repo with a working example of how to connect to web-wallets, build and submit transactions using the serialization lib:
https://github.com/dynamicstrategies/cardano-wallet-connector
All the best!