Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix vft & add vnft #140

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions docs/build/standards/vft.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ sidebar_position: 1
The Vara Fungible Token Standard is the analogue of ERC-20 on Ethereum.
:::

The Vara Fungible Token Standard provides a unified API for smart contracts to implement token functionalities. It encompasses critical operations like token transfer and approvals for third-party spending on the blockchain. Below, we detail the contract state, its interface, and key methods to facilitate these operations.

An example implementation of the VFT standard is available on [GitHub](https://github.com/gear-foundation/standards/tree/master/vft-service).
The Vara Fungible Token Standard provides a unified API for programs to implement token functionalities. It encompasses critical operations like token transfer and approvals for third-party spending on the blockchain. Below is a detailed look at the state of the program, its interface, and key methods to facilitate these operations.

## Functions

Expand Down Expand Up @@ -64,7 +62,7 @@ pub fn transfer(&mut self, to: ActorId, value: U256) -> bool

Transfers the specified `value` of tokens to the account `to`. Returns a boolean value indicating whether the operation

Upon successful execution generates the event:
Upon successful execution, triggers the event:

```rust
Transfer {
Expand All @@ -81,7 +79,7 @@ pub fn transfer_from(&mut self, from: ActorId, to: ActorId, value: U256) -> bool
```
Transfers a specified `value` of tokens `from` one account `to` another, using the allowance mechanism. Value is then deducted from the caller’s allowance. Returns a boolean value indicating whether the operation succeeded.

Upon successful execution generates the event:
Upon successful execution, triggers the event:

```rust
Transfer {
Expand Down Expand Up @@ -143,6 +141,6 @@ pub fn allowance(&self, owner: ActorId, spender: ActorId) -> U256

## Conclusion

By adhering to this standard, smart contracts can ensure interoperability and provide a consistent user experience across different platforms and applications within the blockchain ecosystem.
The provided service is a foundational base for creating your own token, rather than a complete application. It can be extended and inherited to add additional functionality, allowing developers to build upon this framework. The code for this service is available on [GitHub](https://github.com/gear-foundation/standards/tree/master/vft-service).

Using this standard, dApp developers can ensure that their in-app tokens, built on the basis of this standard, will be natively displayed in user wallets without requiring additional integration efforts, assuming that wallet applications also support this standard.
By adhering to this standard, programs ensure interoperability and a consistent user experience across platforms and applications within the blockchain ecosystem. dApp developers can also ensure that their in-app tokens, built on this standard, will be natively displayed in user wallets without additional integration efforts, as long as wallet applications support this standard.
136 changes: 136 additions & 0 deletions docs/build/standards/vnft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
sidebar_label: VNFT
sidebar_position: 2
---

# Vara Non-Fungible Token

:::note
The Vara Non-Fungible Token Standard is the analogue of ERC-721 on Ethereum.
:::

The Vara Non-Fungible Token (VNFT) Standard provides a unified API for programs to implement non-fungible token (NFT) functionalities. It encompasses critical operations like token transfer and approvals for third-party spending on the blockchain. Below is a detailed look at the state of the program, its interface, and key methods to facilitate these operations.

## Functions

```
Approve(approved, token_id)
Transfer(to, token_id)
TransferFrom(from, to, token_id)
BalanceOf(owner)
OwnerOf(token_id)
GetApproved(token_id)
Name()
Symbol()
```

## Events

```
Approval(owner, approved, token_id);
Transfer(from, to, token_id);
```

## Key methods

### `Approve`

```rust
pub fn approve(&mut self, approved: ActorId, token_id: TokenId)
```

This function allows a designated address (`approved`) to transfer a specific token (`token_id`) on behalf of the token owner. It authorizes the `approved` address to handle the given token once. Upon successful execution, it triggers the `Approval` event.

Upon successful execution, triggers the event:

```rust
Approval {
owner: ActorId,
approved: ActorId,
token_id: TokenId,
}
```

### `Transfer`

```rust
pub fn transfer(&mut self, to: ActorId, token_id: TokenId)
```

Transfers the specified `token_id` to the designated account `to`. This method checks the caller’s ownership before executing the transfer.

Upon successful execution, triggers the event:

```rust
Transfer {
from: ActorId,
to: ActorId,
token_id: TokenId,
}
```

### `TransferFrom`

```rust
pub fn transfer_from(&mut self, from: ActorId, to: ActorId, token_id: TokenId)
```

Transfers a specified `token_id` from one account (`from`) to another (`to`), using the approval mechanism. This function ensures that the caller is authorized to make the transfer either as the owner or as an approved address.

Upon successful execution, triggers the event:

```rust
Transfer {
from: ActorId,
to: ActorId,
token_id: TokenId,
}
```

## Query methods

### `name`

Returns the name of the token collection.

```rust
pub fn name(&self) -> &'static str
```

### `symbol`

Returns the symbol of the token collection.

```rust
pub fn symbol(&self) -> &'static str
```

### `balance_of`

Returns the number of tokens owned by a given `owner` address.

```rust
pub fn balance_of(&self, owner: ActorId) -> U256
```

### `owner_of`

Returns the owner of the specified `token_id`.

```rust
pub fn owner_of(&self, token_id: TokenId) -> ActorId
```

### `get_approved`

Returns the address approved for a specific `token_id`.

```rust
pub fn get_approved(&self, token_id: TokenId) -> ActorId
```

## Conclusion

The provided service is a foundational base for creating your own token, rather than a complete application. It can be extended and inherited to add additional functionality, allowing developers to build upon this framework. The code for this service is available on [GitHub](https://github.com/gear-foundation/standards/tree/master/vnft-service).

By adhering to this standard, programs ensure interoperability and a consistent user experience across platforms and applications within the blockchain ecosystem. dApp developers can also ensure that their in-app tokens, built on this standard, will be natively displayed in user wallets without additional integration efforts, as long as wallet applications support this standard.