Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preparing IOTA transactions to be broadcasted
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at https://hribek25.github.io/IOTA101/
// Complete description and story behind the snippet is available at: https://hribek25.github.io/IOTA101/Allchapters_csharp.ipynb.html#445C2B9485C6
// Requirement: Tangle.Net library (!nuget install Tangle.Net)
// Requirement: Newtonsoft Json library (!nuget install Newtonsoft.Json)
#r "Tangle.Net.dll"
#r "Newtonsoft.Json.dll"
using Tangle.Net.Entity;
using Newtonsoft.Json;
var MySeed = "HGW9HB9LJPYUGVHNGCPLFKKPNZAIIFHZBDHKSGMQKFMANUBASSMSV9TAJSSMPRZZU9SFZULXKJ9YLAIUA";
var TargetAddress1 = "CXDUYK9XGHC9DTSPDMKGGGXAIARSRVAFGHJOCDDHWADLVBBOEHLICHTMGKVDOGRU9TBESJNHAXYPVJ9R9";
var TargetAddress2 = "CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW";
var NowIs = DateTime.Now.ToShortDateString(); //this is not important - just to have some meaningful message
var pt = new Transfer() // creating a first transfer (a proposed transaction)
{
Address=new Address(TargetAddress1),
ValueToTransfer=0,
Message=TryteString.FromUtf8String("Here comes a first message. Now is " + NowIs),
Tag=new Tag("HRIBEK999IOTA999TUTORIAL"),
Timestamp = Timestamp.UnixSecondsTimestamp // please note, Tangle.Net library does not enter timestamp for you
};
var pt2 = new Transfer() // creating a second transfer (a proposed transaction)
{
Address = new Address(TargetAddress2),
ValueToTransfer = 0,
Message = TryteString.FromUtf8String("Here comes a second message. Now is " + NowIs),
Tag = new Tag("HRIBEK999IOTA999TUTORIAL"),
Timestamp = Timestamp.UnixSecondsTimestamp // please note, Tangle.Net library does not enter timestamp for you
};
Console.WriteLine("Created transaction objects - mandatory fields only:");
Console.WriteLine(JsonConvert.SerializeObject(pt, Formatting.Indented));
Console.WriteLine(JsonConvert.SerializeObject(pt2, Formatting.Indented));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.