Forge Unveiled

JeanChen

2019/05/10 发布于 技术 分类

文字内容
1. 1 Forge: Unveiled Brought to you by Tyr Chen
2. 2 The crossroad of blockchain
3. What the industry has so far? 3
4. What are missing? 4
5. Can we cross the chasm? 5
6. 6 The Forge Framework
7. Forge Framework is a swiss army knife 7 • Forge CLI: easy to use command to interact with forge, the shell of the forge • Forge core: the kernel of the forge • ABT Chain node: GUI of the forge, with built in explorer and dev tools • Forge simulator: Dev friendly test tool for generating customizable simulation traffic • Forge TX protocols: pluggable protocols that can execute a rich groups of transactions (like smart contracts but a magnitude more powerful) • DID workshop: dev tools for developers to quickly prototype Dapps and DID workflow • Forge compiler: compiler that helps to compile the transaction protocols into hotloadable binaries • Forge Indexer: block indexer that pushes data / states into RDBMS to make things query-able • Forge PubSub: powerful event system with dev-friendly filtering capability
8. Transaction protocols abstract real-world use cases 8
10. 9 Demo 1: 1-click REAL PRODUCTION chain deploy
11. 10 1-click deployment, really?
12. How do arcblock deploy its chains? 11
13. is it just a chain? 12 What we offered is a web-accessible, geo-load-balanced, decentralized app platform!
14. 13 Let's see how to FORGE this!
15. Demo 2: Basic operations with SDK • You may want to check current chain status - good to go! • ForgeSdk.get_chain_info • Now it's time to create a wallet, and declare it to the world • ForgeSdk.create_wallet / ForgeSdk.declare • Then you check your account state, only finding that you have nothing • ForgeSdk.get_account_state • We need to get some free tokens... • ForgeSdk.checkin • Then we can transfer it to others • ForgeSdk.transfer 14
16. As we discussed, there're a lot more... and we will keep evolving the core protocols to fits for various common use cases 15
17. 16 So...what if I want to build something new?
18. 17 Demo 3: I'd issue certi cates and sell them!
19. De ne your certi cate message CertInfo { string no = 1; string title = 2; string signer = 3; google.protobuf.Timestamp expired_at = 4; bytes signature = 5; } 18
20. Process the creation of the certi cate defmodule CoreTx.Cert do defmodule Rpc do @moduledoc false alias ForgeAbi.CertInfo alias Google.Protobuf.Timestamp def create(no, title, expired_at, opts) do # sanity check is skipped... wallet = opts[:wallet] seconds = DateTime.to_unix(expired_at) ts = Timestamp.new(seconds: seconds) cert = CertInfo.new(no: no, title: title, expired_at: ts, signer: wallet.address) sig = ForgeSdk.Wallet.Util.sign!(wallet, CertInfo.encode(cert)) data = ForgeSdk.encode_any!(%{cert signature: sig}) itx = ForgeAbi.CreateAssetTx.new(readonly: false, transferrable: true, data: data) ForgeSdk.create_asset(itx, opts) end end end 19
21. Wrap it as a transaction protocol and compile! --name: cert version: 0 namespace: CoreTx description: create a new cert proto: cert.proto type_urls: fg:x:cert: ForgeAbi.CertInfo sources: [cert.ex] forge-compiler config.yml 20
22. Install it to forge and use it! 21 # install the protocol Forge.Unsafe.LoadTxs.update_one(data, wallet) # create the certificate hash = CoreTx.Cert.Rpc.create("A9527", "PhD from Carleton University", DateTime.from_naive!(~N[2025-11-15 10:00:00], "Etc/UTC"), wallet: walle ForgeSdk.get_address(hash) # tyr want this cert {w, _} = ForgeSdk.create_wallet(moniker: "tyrchen", passphrase: "abcd1234") # tyr need some money ForgeSdk.checkin(wallet: w) # now exchange! e1 = ForgeAbi.ExchangeInfo.new(assets: [address]) e2 = ForgeAbi.ExchangeInfo.new(value: ForgeSdk.token_to_unit(10)) # the owner of the cert sign the exchange tx tx = ForgeSdk.prepare_exchange(ForgeAbi.ExchangeTx.new(sender: e1, receiver: e2, to: w.address), wallet: wallet) # tyr multisign the tx and send it to the chain tx1 = ForgeSdk.finalize_exchange(tx, w) ForgeSdk.send_tx(tx: tx1) # how's the certificate now? ForgeSdk.get_asset_state(address: address) > ForgeSdk.display
23. 22