温馨提示:文章均来自网络用户自主投稿,风险性未知,涉及注册投资需谨慎,因此造成损失本站概不负责! |
“我们相信,一个开放、即时、匿名、低成本、值得信赖的价值互联网更符合未来社会生太系统的经济机会和商业价值。”
目录基础知识
1.什么是v.systems?
v.systems(也称为VSYS)是一个区块涟数据库云项目,旨在为区块涟数据库创建安全的基础设施平台。 该项目将提供去中芯化的云数据库技术来执行复杂的去中芯化应用程序,并有效支持数万亿条区块涟的运行,具有高可扩展性、持久性和高性能。
2. 什么是随机数?
在Vsys涟中,可以通过助记词导入很多账户,并使用Nonce来区分这些账户。 如果助记词和Nonce一致,则导入的账户闭须相同。 因此,在导入助记词时,请确认要导入的账户的Nonce值,以确保导入的账户是您想要的账户。
3.什么是VSYS銭包?
开发准备
1、准备SDK:
3. 使用简単:
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet,nodeUrl);
Integer height = blockchain.getHeight();
System.out.println("height = " + height);
结果:
height = 10742516
实际开发
1.随机生成账户
int nonce = 0; //nonce,在上面提及到。
Account account = new Account(NetworkType.Mainnet, mnemonic, nonce);
System.out.println("mnemonic: " + mnemonic);
System.out.println("privateKey: " + account.getPrivateKey());
System.out.println("publicKey: " + account.getPublicKey());
System.out.println("address: " + account.getAddress());
结果:
mnemonic: foil select play devote tail initial multip away ancient trend tuition valve net foot olive
privateKey: 97JX39eeV3Q7SZpo941UeTUdokoaWdB企鹅6Y647BDFXuN
publicKey: 3k2hdcoiryNKrESg7s2RWBjToXUANrj8Ld4zia3Uvvtn
address: ARAEswrPshwQDKk8n3WEVMMqBr4cthyvp
2. 生成账户的助记词
String mnemonic = "foil select play devote tail initial multip away ancient trend tuition valve net foot olive";
int nonce = 0; //nonce,在上面提及到。
Account account = new Account(NetworkType.Mainnet, mnemonic, nonce);
System.out.println("mnemonic: " + mnemonic);
System.out.println("privateKey: " + account.getPrivateKey());
System.out.println("publicKey: " + account.getPublicKey());
System.out.println("address: " + account.getAddress());
结果:
mnemonic: foil select play devote tail initial multip away ancient trend tuition valve net foot olive
privateKey: 97JX39eeV3Q7SZpo941UeTUdokoaWdB企鹅6Y647BDFXuN
publicKey: 3k2hdcoiryNKrESg7s2RWBjToXUANrj8Ld4zia3Uvvtn
address: ARAEswrPshwQDKk8n3WEVMMqBr4cthyvp
注意:同样的助记词和同样的nonce才能得到维一的地址。
3. 私钥生成账户
String privateKey = "97JX39eeV3Q7SZpo941UeTUdokoaWdB企鹅6Y647BDFXuN";
Account account = new Account(NetworkType.Mainnet,privateKey);
System.out.println("privateKey: " + account.getPrivateKey());
System.out.println("publicKey: " + account.getPublicKey());
System.out.println("address: " + account.getAddress());
结果:
privateKey: 97JX39eeV3Q7SZpo941UeTUdokoaWdB企鹅6Y647BDFXuN
publicKey: 3k2hdcoiryNKrESg7s2RWBjToXUANrj8Ld4zia3Uvvtn
address: ARAEswrPshwQDKk8n3WEVMMqBr4cthyvp
4. 保持平衡
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet, nodeUrl);
String address = "ARHXxk7ZYLpALQhFGKX4GjvRSYQi3ZztRnV";
Long balance = blockchain.getBalance(address);
System.out.println("balance = " + balance);
结果:
balance = 27026944953361
5. 获取代币余额
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet, nodeUrl);
String address = "ARHXxk7ZYLpALQhFGKX4GjvRSYQi3ZztRnV";
String tokenId = "TWaN4DqnRMdUS5d1ohCn9Vh9VdGWDLm9Um1jHbQiF";
TokenBalance balance = blockchain.getTokenBalance(address,tokenId);
System.out.println("balance = " + balance.getBalance());
结果:
balance = 0
6. 转账
String privateKey = "xxx 你的私钥";
String toAddress = "你要转给谁的地址";
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet, nodeUrl);
Long amount = 1 * Blockchain.V_UNITY; // Send 1.0 V coin
PaymentTransaction tx = TransactionFactory.buildPaymentTx(toAddress, amount);
Account account = new Account(NetworkType.Mainnet, privateKey);
// Usage 1: for hot wallet sending transaction
Transaction result = account.sendTransaction(blockchain, tx);
String id = result.getId();//即交换的ID
//拿到ID就可以查询交换状态,是否成功等待。
// Usage 2: for cold wallet signing transaction
String signature = account.getSignature(tx);
7. 代币转账
String privateKey = "xxx 你的私钥";
String toAddress = "你要转给谁的地址";
String tokenId = "代币ID";
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet, nodeUrl);
ContractType tokenType = blockchain.getContractTypeByTokenId(tokenId);
TokenInfo tokenInfo = blockchain.getTokenInfo(tokenId);
Long tokenUnity = tokenInfo.getUnity();
Long amount = 1 * tokenUnity; // Send 1.0 Token
ExecuteContractFunctionTransaction tx = TransactionFactory.buildSendTokenTx(tokenId, tokenType, toAddress, amount);
String txId = tx.getId(); // get Tx ID offline
// Usage 1: for hot wallet sending transaction
Account account = new Account(NetworkType.Mainnet, privateKey);
Transaction result = account.sendTransaction(blockchain, tx);
String id = result.getId();//即交换的ID
//拿到ID就可以查询交换状态,是否成功等待。
// Usage 2: for cold wallet signing transaction
String signature = account.getSignature(tx);
8.查询交换明细
String txId = "Dsc6iCLr4WhXYtJqdwQkjrp3LA4gZ23vyme2YUw7nMFC";
String nodeUrl = "https://wallet.v.systems/api";
Blockchain blockchain = new Blockchain(NetworkType.Mainnet, nodeUrl);
Transaction transaction = blockchain.getTransactionById(txId);
String json = ON.toONString(transaction); //为了方便查看我转成json
System.out.println(json);
结果:
{"amount":3600000000,"height":10742584,"id":"Dsc6iCLr4WhXYtJqdwQkjrp3LA4gZ23vyme2YUw7nMFC","recipient":"ARHXxk7ZYLpALQhFGKX4GjvRSYQi3ZztRnV","status":"Success","timestamp":1586581452003689785,"type":5}
可以看到status为Success就表示成功了
总结
1. 开发VSYS銭包比之前文章中的BTC、ETH、EOS简単很多。 主要是提供相关的SDK供我们使用。 **的问题可能是组织 SDK。
2.如果您在开发过程中遇到任何问题,可以给我留言。
参考
github:
管方网站:
涟鱼科技以普世价值和科学思维为基础,以去中芯化和多中芯信任为核心,结合传统互联网的优势,通过底层技术建立科学、公证、透明的姿产增值+再分配生太系统。 (ID:联宇技术)
2023-09-27 09:54:51
,某些文章具有时效性,若有错误或已失效,请在下方联系网站客服。1 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请联系客服QQ1041045050进行删除处理。
2 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
3 风险提示:合作之前建议签订合同,汇一线首码网作为信息共享平台无法对信息的真实性及准确性做出判断,不承担任何财产损失和法律责任,若您不同意该提示,请关闭网页且不要在本站拓展任何合作,否则造成的任何损失由您个人承担。