Skip to content

Instantly share code, notes, and snippets.

@Hribek25
Hribek25 / IOTA101_0FF479CB6C0A.js
Last active September 24, 2019 10:30
Generating IOTA addresses from a seed: API call Get_new_addresses()
// 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_javascript.ipynb.html#0FF479CB6C0A
// Requirement: A core module of IOTA Javascript Library (!npm install @iota/core)
var iotalib = require('@iota/core');
var NodeURL = "https://nodes.thetangle.org:443";
var MySeed = "WKQDUZTGFKSSLACUCHHLZRKZBHSDSCEBHKUPDLKFBQALEBKDMFRPUQGZRXAADPG9TSRTZGGBZOFRJCFMM";
var iota = iotalib.composeAPI({
@Hribek25
Hribek25 / IOTA101_67D98D069B61.js
Last active September 24, 2019 10:30
Generating a seed: a general approach
// 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_javascript.ipynb.html#67D98D069B61
//based on https://gist.github.com/SteveFromTheOffice/c8448a09352337386f135a16bbb20d93
//modified by Petr Zizka
var GenerateSeed = function () {
const length = 81; // The length of the seed and int array.
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9"; // The allowed characters in the seed.
var result = new Array(length); // An empty array to store the seed characters.
@Hribek25
Hribek25 / IOTA101_696A395DC61B.js
Last active September 24, 2019 10:30
Basic node interaction: API call Get_node_info()
// 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_javascript.ipynb.html#696A395DC61B
// Requirement: A core module of IOTA Javascript Library (!npm install @iota/core)
var iotalib = require('@iota/core'); // loading iota.js core module. More info: https://github.com/iotaledger/iota.js/tree/next/packages/core
// composerAPI initialization of the iota.js library
var iota = iotalib.composeAPI({
'provider': 'https://nodes.thetangle.org:443'
});
@Hribek25
Hribek25 / IOTA101_3BB8C879CCAE.js
Last active September 24, 2019 10:30
Conversion: trytes and trits
// 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_javascript.ipynb.html#3BB8C879CCAE
// Requirement: A converter module of IOTA Javascript Library (!npm install @iota/converter)
var Converter = require('@iota/converter') //loading helping converter module of iota.js library. More info: https://github.com/iotaledger/iota.js/tree/next/packages/converter#module_converter.trits
var Trytes = "YZJEATEQ9JKLZ" //some data encoded in Trytes
console.log(Trytes)
console.log("Number of Trytes: %s" , Trytes.length)
@Hribek25
Hribek25 / IOTA101_07CFD43B146C.py
Last active October 8, 2019 13:20
Sending IOTA transaction in more granular way: API calls Prepare_transfer() and Send_transfer()
# 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_python.ipynb.html#07CFD43B146C
# Requirement: PyOTA library (!pip install pyota)
import iota
from datetime import datetime
from pprint import pprint
MySeed = b"HGW9HB9LJPYUGVHNGCPLFKKPNZAIIFHZBDHKSGMQKFMANUBASSMSV9TAJSSMPRZZU9SFZULXKJ9YLAIUA"
TargetAddress1 = b"CXDUYK9XGHC9DTSPDMKGGGXAIARSRVAFGHJOCDDHWADLVBBOEHLICHTMGKVDOGRU9TBESJNHAXYPVJ9R9"
@Hribek25
Hribek25 / IOTA101_00663E550ADF.py
Last active October 8, 2019 13:20
Sending IOTA transaction in a single call: API call Send_transfer()
# 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_python.ipynb.html#00663E550ADF
# Requirement: PyOTA library (!pip install pyota)
import iota
from datetime import datetime
from pprint import pprint
MySeed = b"HGW9HB9LJPYUGVHNGCPLFKKPNZAIIFHZBDHKSGMQKFMANUBASSMSV9TAJSSMPRZZU9SFZULXKJ9YLAIUA"
TargetAddress1 = b"CXDUYK9XGHC9DTSPDMKGGGXAIARSRVAFGHJOCDDHWADLVBBOEHLICHTMGKVDOGRU9TBESJNHAXYPVJ9R9"
@Hribek25
Hribek25 / IOTA101_445C2B9485C6.py
Last active September 24, 2019 10:30
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_python.ipynb.html#445C2B9485C6
# Requirement: PyOTA library (!pip install pyota)
import iota
from datetime import datetime
from pprint import pprint
MySeed = b"HGW9HB9LJPYUGVHNGCPLFKKPNZAIIFHZBDHKSGMQKFMANUBASSMSV9TAJSSMPRZZU9SFZULXKJ9YLAIUA"
TargetAddress1 = b"CXDUYK9XGHC9DTSPDMKGGGXAIARSRVAFGHJOCDDHWADLVBBOEHLICHTMGKVDOGRU9TBESJNHAXYPVJ9R9"
@Hribek25
Hribek25 / IOTA101_C65223B0864A.py
Last active September 24, 2019 10:30
Validating IOTA address
# 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_python.ipynb.html#C65223B0864A
# Requirement: PyOTA library (!pip install pyota)
import iota
import sys
from pprint import pprint
InputAddr = b"CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RWTHBIRSXTA"
if len(InputAddr)!=90:
@Hribek25
Hribek25 / IOTA101_39B011574CF0.py
Last active September 24, 2019 10:30
IOTA address and checksum
# 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_python.ipynb.html#39B011574CF0
# Requirement: PyOTA library (!pip install pyota)
import iota
from pprint import pprint
# some IOTA address
Adr = iota.Address(b"CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW")
@Hribek25
Hribek25 / IOTA101_2508A6FF9241.py
Last active September 24, 2019 10:30
Generating IOTA addresses from a seed (#2)
# 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_python.ipynb.html#2508A6FF9241
# Requirement: PyOTA library (!pip install pyota)
from iota.crypto.addresses import AddressGenerator
from pprint import pprint
MySeed = b"WKQDUZTGFKSSLACUCHHLZRKZBHSDSCEBHKUPDLKFBQALEBKDMFRPUQGZRXAADPG9TSRTZGGBZOFRJCFMM"
#security level is defined during generator init