template.md in flow_client-0.2.0 vs template.md in flow_client-0.2.1
- old
+ new
@@ -60,11 +60,11 @@
```
## Querying the Flow Network
After you have established a connection with an access node, you can query the Flow network to retrieve data about blocks, accounts, events and transactions. We will explore how to retrieve each of these entities in the sections below.
### Get Blocks
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client)
Query the network for block by id, height or get the latest block.
📖 **Block ID** is SHA3-256 hash of the entire block payload. This hash is stored as an ID field on any block response object (ie. response from `GetLatestBlock`).
@@ -102,11 +102,11 @@
@signatures=["919f93cb66f11f88b86aec9e89cbb66aebe5846a9246f04661cf9094c8bb5e1e7e89da3f0d688b0e27b31cec551f2f89aa755aabed5b44ba0c2cc6e87c72eba2a33d64219df0ee4185ed9ce78f77721d519f3c6bebe0c95bffc9a98ff706001d"],
@timestamp=2021-11-03 09:00:38.000037 +0200>
```
### Get Account
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient%2FClient:get_account)
Retrieve any account from Flow network's latest block or from a specified block height.
📖 **Account address** is a unique account identifier. Be mindful about the `0x` prefix, you should use the prefix as a default representation but be careful and safely handle user inputs without the prefix.
@@ -131,11 +131,11 @@
@keys=[#<FlowClient::AccountKey:0x00007f84eb281848 @hash_algo="SHA3-256", @index=0, @public_key="6f489d349fee5a0436cac0605820429907b05eb772c194ebf429d71caee70d2b2499be9e6c4e17d81f157466ac3d793b217fd091e89a172b11cac81d2378385b", @revoked=false, @sequence_number=0, @weight=1000>]>
```
### Get Transactions
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#get_transaction-instance_method)
Retrieve transactions from the network by providing a transaction ID. After a transaction has been submitted, you can also get the transaction result to check the status.
📖 **Transaction ID** is a hash of the encoded transaction payload and can be calculated before submitting the transaction to the network.
@@ -231,11 +231,11 @@
@status_code=0>
```
### Get Events
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#get_events-instance_method)
Retrieve events by a given type in a specified block height range or through a list of block IDs.
📖 **Event type** is a string that follow a standard format:
```
@@ -275,11 +275,11 @@
@transaction_index=1,
@type="A.7e60df042a9c0868.FlowToken.TokensWithdrawn">]>]
```
### Get Collections
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#get_collection_by_id-instance_method)
Retrieve a batch of transactions that have been included in the same block, known as ***collections***.
Collections are used to improve consensus throughput by increasing the number of transactions per block and they act as a link between a block and a transaction.
📖 **Collection ID** is SHA3-256 hash of the collection payload.
@@ -292,11 +292,11 @@
```ruby
#<FlowClient::Collection:0x00007f9bf4239280 @id="f2a15028f4502c088d5460f1f086b65c0a71bb3da44bde6c6c5dcce254ddf849", @transaction_ids=["eee1fe5350ea47f0f88b2b742d9487f48026b97f3983b6fd4c7b03ced888d326"]>
```
### Execute Scripts
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#execute_script-instance_method)
Scripts allow you to write arbitrary non-mutating Cadence code on the Flow blockchain and return data. You can learn more about [Cadence and scripts here](https://docs.onflow.org/cadence/language/), but we are now only interested in executing the script code and getting back the data.
We can execute a script using the latest state of the Flow blockchain or we can choose to execute the script at a specific time in history defined by a block height or block ID.
@@ -310,11 +310,11 @@
pub fun main(a: Int): Int {
return a + 10
}
}
-args = [{ type: 'Int', value: "1" }.to_json]
+args = [FlowClient::CadenceType.Int(1)]
res = client.execute_script(script, args)
```
```ruby
# Complex script
@@ -405,11 +405,11 @@
📖 **Reference block** specifies an expiration window (measured in blocks) during which a transaction is considered valid by the network.
A transaction will be rejected if it is submitted past its expiry block. Flow calculates transaction expiry using the _reference block_ field on a transaction.
A transaction expires after `600` blocks are committed on top of the reference block, which takes about 10 minutes at average Mainnet block rates.
### Build Transactions
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Transaction)
Building a transaction involves setting the required properties explained above and producing a transaction object.
Here we define a simple transaction script that will be used to execute on the network and serve as a good learning example.
@@ -454,11 +454,11 @@
```
After you have successfully [built a transaction](#build-transactions) the next step in the process is to sign it.
### Sign Transactions
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Transaction)
Flow introduces new concepts that allow for more flexibility when creating and signing transactions.
Before trying the examples below, we recommend that you read through the [transaction signature documentation](https://docs.onflow.org/concepts/accounts-and-keys/).
After you have successfully [built a transaction](#build-transactions) the next step in the process is to sign it. Flow transactions have envelope and payload signatures, and you should learn about each in the [signature documentation](https://docs.onflow.org/concepts/accounts-and-keys/#anatomy-of-a-transaction).
@@ -476,11 +476,11 @@
Signatures can be generated more securely using keys stored in a hardware device such as an [HSM](https://en.wikipedia.org/wiki/Hardware_security_module). The `crypto.Signer` interface is intended to be flexible enough to support a variety of signer implementations and is not limited to in-memory implementations.
Simple signature example:
```ruby
-account = FlowClient::Account.new(address: 0x01)
+account = client.get_account("0x01")
signer = FlowClient::LocalSigner.new("<private key hex>")
transaction.proposer_address = account.address
transaction.proposer_key_index = account.keys.first.index
transaction.proposer_key_sequence_number = account.keys.first.sequence_number
@@ -501,11 +501,11 @@
| Account | Key ID | Weight |
| ------- | ------ | ------ |
| `0x01` | 1 | 1.0 |
```ruby
-account = FlowClient::Account.new(address: 0x01)
+account = client.get_account("0x01")
transaction = FlowClient::Transaction.new
transaction.reference_block_id = client.get_latest_block.id
transaction.gas_limit = 100
transaction.proposer_address = account.address
@@ -530,11 +530,11 @@
| ------- | ------ | ------ |
| `0x01` | 1 | 0.5 |
| `0x01` | 2 | 0.5 |
```ruby
-account = FlowClient::Account.new(address: 0x01)
+account = client.get_account("0x01")
transaction = FlowClient::Transaction.new
transaction.reference_block_id = client.get_latest_block.id
transaction.gas_limit = 100
transaction.proposer_address = account.address
@@ -561,14 +561,14 @@
| `0x01` | 1 | 1.0 |
| `0x02` | 3 | 1.0 |
```ruby
payer_signer = FlowClient::LocalSigner.new("<private key hex>")
-payer_account = FlowClient::Account.new(address: 0x02)
+payer_account = client.get_account("0x02")
proposer_signer = FlowClient::LocalSigner.new("<private key hex>")
-proposer_account = FlowClient::Account.new(address: 0x01)
+proposer_account = client.get_account("0x01")
@transaction = FlowClient::Transaction.new
@transaction.reference_block_id = client.get_latest_block.id
@transaction.gas_limit = gas_limit
@@ -597,14 +597,14 @@
| `0x01` | 1 | 1.0 |
| `0x02` | 3 | 1.0 |
```ruby
payer_signer = FlowClient::LocalSigner.new("<private key hex>")
-payer_account = FlowClient::Account.new(address: 0x02)
+payer_account = client.get_account("0x02")
proposer_signer = FlowClient::LocalSigner.new("<private key hex>")
-proposer_account = FlowClient::Account.new(address: 0x01)
+proposer_account = client.get_account("0x01")
@transaction = FlowClient::Transaction.new
@transaction.reference_block_id = client.get_latest_block.id
@transaction.gas_limit = gas_limit
@@ -635,14 +635,14 @@
| `0x02` | 3 | 0.5 |
| `0x02` | 4 | 0.5 |
```ruby
payer_signer = FlowClient::LocalSigner.new("<private key hex>")
-payer_account = FlowClient::Account.new(address: 0x02)
+payer_account = client.get_account("0x02")
proposer_signer = FlowClient::LocalSigner.new("<private key hex>")
-proposer_account = FlowClient::Account.new(address: 0x01)
+proposer_account = client.get_account("0x01")
@transaction = FlowClient::Transaction.new
@transaction.reference_block_id = client.get_latest_block.id
@transaction.proposer_address = proposer_account.address
@@ -659,11 +659,11 @@
@transaction.add_envelope_signature(payer_account.address, payer_account.keys[3].index, payer_signer)
```
### Send Transactions
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#send_transaction-instance_method)
After a transaction has been [built](#build-transactions) and [signed](#sign-transactions), it can be sent to the Flow blockchain where it will be executed. If sending was successful you can then [retrieve the transaction result](#get-transactions).
```ruby
@@ -673,11 +673,11 @@
end
```
### Create Accounts
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Client#create_account-instance_method)
On Flow, account creation happens inside a transaction. Because the network allows for a many-to-many relationship between public keys and accounts, it's not possible to derive a new account address from a public key offline.
The Flow VM uses a deterministic address generation algorithm to assigen account addresses on chain. You can find more details about address generation in the [accounts & keys documentation](https://docs.onflow.org/concepts/accounts-and-keys/).
@@ -698,17 +698,17 @@
Account creation happens inside a transaction, which means that somebody must pay to submit that transaction to the network. We'll call this person the account creator. Make sure you have read [sending a transaction section](#send-transactions) first.
```ruby
# The account that will pay for the creation of the new account
-account = FlowClient::Account.new(address: "f8d6e0586b0a20c7")
+payer_account = client.get_account("f8d6e0586b0a20c7")
# Create an in-memory signer with the payer's private key
signer = FlowClient::LocalSigner.new("4d9287571c8bff7482ffc27ef68d5b4990f9bd009a1e9fa812aae08ba167d57f")
# Generate a public key for the new account
_private_key, public_key = FlowClient::Crypto.generate_key_pair(FlowClient::Crypto::Curves::P256)
# Create the account
-res = client.create_account([public_key], { "ContractName": "<contract cadence code>" }, account, signer)
+res = client.create_account([public_key], { "ContractName": "<contract cadence code>" }, payer_account, signer)
```
```ruby
#<FlowClient::Account:0x00007f84eb36b650
@address="01cf0e2f2f715450",
@@ -724,11 +724,11 @@
```ruby
res.address
```
### Generate Keys
-[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://github.com/glucode/flow_client)
+[<img src="https://raw.githubusercontent.com/onflow/sdks/main/templates/documentation/ref.svg" width="130">](https://www.rubydoc.info/gems/flow_client/FlowClient/Crypto#generate_key_pair-class_method)
Flow uses [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) signatures to control access to user accounts. Each key pair can be used in combination with the `SHA2-256` or `SHA3-256` hashing algorithms.
Here's how to generate an ECDSA private key for the P-256 (secp256r1) curve.
@@ -742,6 +742,6 @@
The example above uses an ECDSA key pair on the P-256 (secp256r1) elliptic curve. Flow also supports the secp256k1 curve used by Bitcoin and Ethereum. Read more about [supported algorithms here](https://docs.onflow.org/concepts/accounts-and-keys/#supported-signature--hash-algorithms).
```ruby
private_key, public_key = FlowClient::Crypto.generate_key_pair(FlowClient::Crypto::Curves::SECP256K1)
-```
+```
\ No newline at end of file