IOTA
參考:https://github.com/iotaledger/wallet
參考:https://github.com/iotaledger/iota.js
參考:https://github.com/schierlm/private-iota-testnet
參考:https://docs.iota.org/
基礎環境
npm install -g electron
npm install -g bower
npm install ajv@^5.0.0
構建自己的Snapshot.txt
進入private-iota-tetstnet-master文件目錄
mvn package
分配2,779,530,283,277,761個可用的iota到指定的地址上
java -jar target/iota-testnet-tools-0.1-SNAPSHOT-jar-with-dependencies.jar SnapshotBuilder
將Snapshot.txt文件與iri-1.4.2.4.jar放在一個文件夾后開啟服務
java -jar iri-1.4.2.4.jar --testnet --testnet-no-coo-validation --snapshot=Snapshot.txt -p 11219
創建里程碑
java -jar target/iota-testnet-tools-0.1-SNAPSHOT-jar-with-dependencies.jar Coordinator localhost 11219
搭建錢包
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
安裝庫
npm install iota.lib.js
可能遇到的問題
- 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]
- ubuntu默認安裝JAVA的openjdk版本沒有tools.jar的問題
sudo apt-get install openjdk-8-jdk
- /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
- ubuntu默認沒有該庫
+sudo apt -y install libgconf2-4
-
Gtk-Message: 04:25:25.218: Failed to load module "canberra-gtk-module"
sudo apt-get install libcanberra-gtk-module
-
context mismatch in svga_sampler_view_destroy
- echo "export SVGA_VGPU10=0" >> ~/.bashrc
示例腳本
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)
}
});