import "github.com/nebulouslabs/sia.types" // create a new transaction tx := types.Transaction{ // set the sender's address SiafundInputs: []types.SiafundInput{ { ParentID: "abc123", Signatures: []types.TransactionSignature{{}}, UnlockConditions: types.UnlockConditions{}, }, }, // set the recipient's address and the amount to be transferred SiafundOutputs: []types.SiafundOutput{ { Value: types.NewCurrency64(100), Address: types.UnlockHash{}, }, }, }
import "github.com/nebulouslabs/sia.types" // create an empty transaction tx := types.Transaction{}; // add a new SiafundInput to the transaction newInput := types.SiafundInput{ ParentID: "def456", Signatures: []types.TransactionSignature{{}}, UnlockConditions: types.UnlockConditions{}, } tx.SiafundInputs = append(tx.SiafundInputs, newInput)
import "github.com/nebulouslabs/sia.types" // create some SiafundOutputs output1 := types.SiafundOutput{ Value: types.NewCurrency64(50), Address: types.UnlockHash{}, } output2 := types.SiafundOutput{ Value: types.NewCurrency64(75), Address: types.UnlockHash{}, } // add them to a transaction tx := types.Transaction{ SiafundOutputs: []types.SiafundOutput{output1, output2}, } // calculate the total value of all the outputs in the transaction totalValue := types.NewCurrency64(0) for _, output := range tx.SiafundOutputs { totalValue = totalValue.Add(output.Value) }