Skip to content

Commit fbf8d2f

Browse files
committed
chore: Update versions and dependencies
1 parent 701fab1 commit fbf8d2f

File tree

7 files changed

+78
-11
lines changed

7 files changed

+78
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
exclude = ["examples/"]
1010

1111
[workspace.package]
12-
version = "2.3.1"
12+
version = "2.3.2"
1313

1414
# Special triple # comment for ci.
1515
[patch.crates-io]

examples/fungible-token/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cargo test --package fungible-token -- --nocapture
3030

3131
## Deploy
3232

33-
Set contract account $CONTRACT_ID
33+
This smart contract will get deployed to your Utility Net account. For this example, please create a new Utility Net account. Because Utility Net allows the ability to upgrade contracts on the same account, initialization functions must be cleared. If you'd like to run this example on a Utility Net account that has had prior contracts deployed, please use the `unc-cli` command `unc delete`, and then recreate it in Wallet. To create (or recreate) an account, please follow the directions in [Utility Net Wallet](https://chromewebstore.google.com/detail/mywallets-v1/poljcmobchfooceghefdokchdkfmlcbk) or [Cli wallet](https://github.com/utnet-org/utility-cli-rs/releases/tag/v0.15.0).
3434

3535
```sh
3636
# create account and import account in testnet
@@ -58,13 +58,13 @@ FT contract should be initialized before usage.
5858
The next command will initialize the contract using the `new` method:
5959

6060
```bash
61-
unc contract call-function as-transaction $CONTRACT_ID new json-args '{"owner_id": "'$CONTRACT_ID'", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "EXLT", "decimals": 8 }}' prepaid-gas '300 TeraGas' attached-deposit '0 unc' sign-as $CONTRACT_ID network-config testnet sign-with-legacy-keychain send
61+
unc contract call-function as-transaction $CONTRACT_ID new json-args '{"owner_id": "'$CONTRACT_ID'", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "AI", "decimals": 8 }}' prepaid-gas '300 TeraGas' attached-deposit '0 unc' sign-as $CONTRACT_ID network-config testnet sign-with-legacy-keychain send
6262
```
6363

6464
To get the fungible token metadata:
6565

6666
```bash
67-
unc contract call-function as-read-only 039b331bede0513d50e3edd083800fc9057da0a519aaf5a26efa2ef2e3c236a4 ft_metadata text-args '' network-config testnet now
67+
unc contract call-function as-read-only $CONTRACT_ID ft_metadata text-args '' network-config testnet now
6868
```
6969

7070
## Transfer
@@ -105,7 +105,7 @@ unc contract call-function as-read-only $CONTRACT_ID ft_balance_of text-args '{"
105105
Transfer tokens to Bob from the contract that minted these fungible tokens, exactly 1 attoUNC of deposit should be attached:
106106

107107
```sh
108-
unc contract call-function as-transaction $CONTRACT_ID ft_transfer json-args '{"receiver_id": "'$BOB_ACCOUNT'", "amount": "19"}' prepaid-gas '300 TeraGas' attached-deposit '0.000000000000000000000001 unc' sign-as $CONTRACT_ID network-config testnet sign-with-legacy-keychain send
108+
unc contract call-function as-transaction $CONTRACT_ID ft_transfer json-args '{"receiver_id": "'$BOB_ACCOUNT'", "amount": "19"}' prepaid-gas '300 TeraGas' attached-deposit '1 attounc' sign-as $CONTRACT_ID network-config testnet sign-with-legacy-keychain send
109109

110110
```
111111

examples/non-fungible-token/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "non-fungible-token-wrapper"
3-
version = "0.0.2"
3+
version = "0.1.0"
44
authors = ["Utility Inc <hello@utnet.org>"]
55
edition = "2021"
66

examples/non-fungible-token/README.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Non-fungible Token (NFT)
33

44
Example implementation of a [non-fungible token] contract which uses [unc-contract-standards].
55

6-
[non-fungible token]: https://nomicon.io/Standards/NonFungibleToken/README.html
6+
[non-fungible token]: https://xxx.io/Standards/NonFungibleToken/README.html
77
[unc-contract-standards]: https://github.com/utnet-org/utility-sdk-rs/tree/master/unc-contract-standards
88

99
NOTES:
1010

1111
- The maximum balance value is limited by U128 (2**128 - 1).
1212
- JSON calls should pass [U128] or [U64] as a base-10 string. E.g. "100".
13-
- The core NFT standard does not include escrow/approval functionality, as `nft_transfer_call` provides a superior approach. Please see the approval management standard if this is the desired approach.
13+
- The core NFT standard does not include escrow/approval functionality, as `nft_transfer_call` provides a superior approach. An escrow system can, of course, be added as a separate contract or additional functionality within this contract.
1414

1515
## Building
1616

@@ -27,3 +27,70 @@ To test run:
2727
```bash
2828
cargo test --workspace --package non-fungible-token -- --nocapture
2929
```
30+
31+
## Deploy
32+
33+
This smart contract will get deployed to your Utility Net account. For this example, please create a new Utility Net account. Because Utility Net allows the ability to upgrade contracts on the same account, initialization functions must be cleared. If you'd like to run this example on a Utility Net account that has had prior contracts deployed, please use the `unc-cli` command `unc delete`, and then recreate it in Wallet. To create (or recreate) an account, please follow the directions in [Utility Net Wallet](https://chromewebstore.google.com/detail/mywallets-v1/poljcmobchfooceghefdokchdkfmlcbk) or [Cli wallet](https://github.com/utnet-org/utility-cli-rs/releases/tag/v0.15.0).
34+
35+
In the project root, create account and import account (a.k.a log in) to your newly created account with `unc-cli` by following the instructions after this command.
36+
37+
unc account import-account using-private-key ed25519:5DwmxYXw3Dy6fwF7Ty9eiDyGGui72xY1bFT7KyzxhckNZ988JA2wPEMZxCKsVUvSmwHm2fmNUra7QozwhHE73HMw network-config testnet
38+
39+
To make this tutorial easier to copy/paste, we're going to set an environment variable for our account id. In the below command, replace `MY_ACCOUNT_NAME` with the account name we just logged in with, including the `.testnet`:
40+
41+
export NFT_ID=ce8f91bc4fe16c1ecae01276a19a8b582135629845ac32e7bf980324d5318ace
42+
43+
We can tell if the environment variable is set correctly if our command line prints the account name after this command:
44+
45+
echo $NFT_ID
46+
47+
Now we can deploy the compiled contract in this example to your account:
48+
49+
unc contract deploy $NFT_ID use-file res/non_fungible_token.wasm without-init-call network-config testnet sign-with-legacy-keychain send
50+
51+
NFT contract should be initialized before usage. More info about the metadata at [xxx.io](https://xxx.io/Standards/NonFungibleToken/Metadata.html). But for now, we'll initialize with the default metadata.
52+
53+
unc contract call-function as-transaction $NFT_ID new_default_meta json-args '{"owner_id": "'$NFT_ID'"}' prepaid-gas '30 TeraGas' attached-deposit '0 unc' sign-as $NFT_ID network-config testnet sign-with-keychain send
54+
55+
We'll be able to view our metadata right after:
56+
57+
unc contract call-function as-read-only $NFT_ID nft_metadata text-args '' network-config testnet now
58+
59+
Then, let's mint our first token. This will create a NFT based on Olympus Mons where only one copy exists:
60+
61+
unc contract call-function as-transaction $NFT_ID nft_mint json-args '{"token_id": "0", "token_owner_id": "'$NFT_ID'", "token_metadata": { "title": "Olympus Mons", "description": "Tallest mountain in charted solar system", "media": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Olympus_Mons_alt.jpg/1024px-Olympus_Mons_alt.jpg", "copies": 1}}' prepaid-gas '300 TeraGas' attached-deposit '0.1 unc' sign-as $NFT_ID network-config testnet sign-with-keychain send
62+
63+
unc tokens $NFT_ID view-nft-assets $NFT_ID network-config testnet now
64+
65+
## Transferring our NFT
66+
67+
Let's set up an account to transfer our freshly minted token to. This account will be a account of the Utility account we logged in with originally via `unc account import`.
68+
69+
```sh
70+
# create account and import account in testnet
71+
unc account create-account fund-later use-auto-generation save-to-folder /home/ubuntu/.unc-credentials/implicit
72+
#such as follows:
73+
# cat /home/ubuntu/.unc-credentials/implicit/b44f5b891131042322601250fd9dd951f9b5ee34d828c8fb30bfb2e856a101c4.json
74+
# {"account_id":"b44f5b891131042322601250fd9dd951f9b5ee34d828c8fb30bfb2e856a101c4","master_seed_phrase":"chimney digital indoor wealth ridge item puzzle slice will cabin panel wine","private_key":"ed25519:4Crf6QpcR6UrakrxEpNjEQ5bF84oCUrW8tDAE5PLyevqJKv4xs1SjARVyLYkV2MXjcsjiAtYkFsLsTgUrUsxfhUf","public_key":"ed25519:D8ra3tox4a5dx6PxQxWJ7xGmASRxzqiWfrhwuNyjC2Td","seed_phrase_hd_path":"m/44'/397'/0'"}
75+
76+
# seed phrase use above terminal output, do not directly use here
77+
unc account import-account using-seed-phrase 'chimney digital indoor wealth ridge item puzzle slice will cabin panel wine' --seed-phrase-hd-path 'm/44'\''/397'\''/0'\''' network-config testnet
78+
# faucet fund account 039b331bede0513d50e3edd083800fc9057da0a519aaf5a26efa2ef2e3c236a4
79+
# Processing transaction...
80+
# Please wait for 6 blocks to confirm, use command: unc transaction view-status <tx_hash>
81+
curl -X POST -H "Content-Type: application/json" -d '{"amount":"10000000000000000000000000", "receiverId":"b44f5b891131042322601250fd9dd951f9b5ee34d828c8fb30bfb2e856a101c4", "contractId":"4e0375672ec30f2efe3a6c5a14ff81d37f1271c439501eac2fb445df262b2c32"}' https://unc-faucet.xyz666.org/api/faucet/tokens
82+
83+
export BOB_ACCOUNT=b44f5b891131042322601250fd9dd951f9b5ee34d828c8fb30bfb2e856a101c4
84+
```
85+
86+
Checking Bob's account for tokens:
87+
88+
unc contract call-function as-read-only $NFT_ID nft_tokens_for_owner text-args '{"account_id": "'$BOB_ACCOUNT'"}' network-config testnet now
89+
90+
Then we'll transfer over the NFT into Bob's account. Exactly 1 attounc of deposit should be attached:
91+
92+
unc contract call-function as-transaction $NFT_ID nft_transfer json-args '{"token_id": "0", "receiver_id": "'$BOB_ACCOUNT'", "memo": "transfer ownership"}' prepaid-gas '30 TeraGas' attached-deposit '1 attounc' sign-as $NFT_ID network-config testnet sign-with-keychain send
93+
94+
Checking Bob's account again shows us that she has the Olympus Mons token.
95+
96+
unc tokens $BOB_ACCOUNT view-nft-assets $NFT_ID network-config testnet now

examples/non-fungible-token/nft/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "non-fungible-token"
3-
version = "1.0.0"
3+
version = "0.1.0"
44
authors = ["Utility Inc <hello@utnet.org>"]
55
edition = "2021"
66

examples/non-fungible-token/test-approval-receiver/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "approval-receiver"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
authors = ["Utility Inc <hello@utnet.org>"]
55
edition = "2021"
66

unc-contract-standards/src/non_fungible_token/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn refund_deposit_to_account(storage_used: u64, account_id: AccountId) {
3333

3434
require!(
3535
required_cost <= attached_deposit,
36-
format!("Must attach {} attoUNC to cover storage", required_cost)
36+
format!("Must attach {} attounc to cover storage", required_cost)
3737
);
3838

3939
let refund = attached_deposit.saturating_sub(required_cost);

0 commit comments

Comments
 (0)