IOTA private chain of simple structures

IOTA

Reference: https: //github.com/iotaledger/wallet
Reference: https: //github.com/iotaledger/iota.js
Reference: https: //github.com/schierlm/private-iota-testnet
Reference: https: / /docs.iota.org/

Basic environment

npm install -g electron
npm install -g bower
npm install ajv@^5.0.0

Build your own Snapshot.txt

Enter the private-iota-tetstnet-master file directory
mvn package
on the address allocation 2,779,530,283,277,761 one iota available to specified
java -jar target/iota-testnet-tools-0.1-SNAPSHOT-jar-with-dependencies.jar SnapshotBuilder
will Snapshot.txt iri-1.4.2.4.jar files in a folder after opening the service
java -jar iri-1.4.2.4.jar --testnet --testnet-no-coo-validation --snapshot=Snapshot.txt -p 11219
to create a milestone
java -jar target/iota-testnet-tools-0.1-SNAPSHOT-jar-with-dependencies.jar Coordinator localhost 11219

Build a wallet

git clone https://github.com/iotaledger/wallet
cd wallet
git clone https://github.com/iotaledger/iri
cd iri       //放进 iri.jar 更改名字为
//更改testnet.json 覆盖 .json
npm install   //会比较久
npm start

Installation Library

npm install iota.lib.js

Possible problems encountered

  1. Could not resolve dependencies for project com.iota:iri:jar:1.7.0-DEV-${git.commit.id.abbrev}: Could not find artifact com.sun:tools:jar:1.8 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [Help 1]
  • The default ubuntu install JAVA version of openjdk no problem of tools.jar
    sudo apt-get install openjdk-8-jdk
  1. /home/xxx/wallet/node_modules/electron/dist/electron: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
  • The library does not default ubuntu
    +sudo apt -y install libgconf2-4
  1. Gtk-Message: 04:25:25.218: Failed to load module "canberra-gtk-module"
    • sudo apt-get install libcanberra-gtk-module
  2. context mismatch in svga_sampler_view_destroy

    • echo "export SVGA_VGPU10=0" >> ~/.bashrc

Sample script

const IOTA = require('iota.lib.js')
const iota = new IOTA({
    host: 'http://127.0.0.1',
    port: 11219
})
const seed = 'APMXGGWAIIQFKV9CYSKKDYUOFZC9FYMGQAELAUJBDW9SMXNNRIYPLOMQYT9SMNLUVFWSHJFDYMGBSMBAL';
const Depth = 3 /* constant defined by IOTA - how deep to look for the tips in the Tangle*/
const MinWeightMagnitude = 13 /* constant defined by IOTA Testnet - the difficulty of PoW*/
const transfers = [
    {
        // where are we sending the transaction to?
        address: 'OHCEFHHAKKNSINQTNK9DPEERVIPOBPKKJWNIFLUEMTJGFZUGASHRMZUGSOGQEJRVFSMFFH9PGBBILNHPZSOILTDFLW',

        // how many tokens are we transferring?
        value: 100,
        
        // do we want to comment on this transaction?
        message: iota.utils.toTrytes('Hello World!')        
    }
]
iota.api.getNodeInfo((error, nodeInfo) => {
    if (error) {
        console.error('getNodeInfo error', error)
    } else {
        console.log('getNodeInfo result', nodeInfo)
    }
});
iota.api.sendTransfer(seed, Depth, MinWeightMagnitude, transfers, (error, transactions) => {
  if (error) {
     console.error('sendTransfer error', error)
  } else {
     console.log('transactions sent!', transactions)
  }
});

Guess you like

Origin www.cnblogs.com/joeat1/p/11008167.html