--- tags: Chia, Spend --- # Chia Standard Transaction: `The italicline is advance knowledge, leave it after you understand basic knowledge` ## :memo: todo list 1. Get spendable coins 2. Calculate change 3. Create coin for change and the given coin 4. Assemble condition 5. solutionForConditions 6. Bundle puzzleReveal, solution and coin as CoinSpend 7. sign every CoinSpend 8. Aggregate signedCoinSpends 9. Assemble SpendBundle 10. pushTransaction ### 1. Get spendable coins **Get coin record from FullNode** * What's FullNode? * What does FullNode record? * What Block? * What does Block record? 2. Calculate change **Spend total spend amount minus target amount.** * How to get balance? 3. Create coin for change and the given coin https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/utils/Wallet.ts#L308 4. Assemble condition https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/utils/Wallet.ts#L324 5. solutionForConditions https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/utils/Wallet.ts#L136 6. Bundle puzzleReveal, solution and coin as CoinSpend https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/utils/Wallet.ts#L365 7. sign every CoinSpend https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/store/WalletStore.ts#L156 8. Aggregate signedCoinSpends https://github.com/hashgreen/yuumi-wallet/blob/b7f783dee3c672e5a6e667421c30998243998150/src/store/WalletStore.ts#L154 9. SpendBundle https://docs.chia.net/docs/04coin-set-model/spend_bundles The only acceptable format to FullNode ```python= class CoinSpend: coin: Coin puzzle_reveal: SerializedProgram solution: SerializedProgram class SpendBundle: coin_spends: List[CoinSpend] aggregated_signature: G2Element ``` 10. pushTransaction https://uat-testnet-jarvan.hash.green/api/docs/index.html#/Addon/post_v1_addon_push_tx