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

Feature/contracts #5

Merged
merged 5 commits into from
Dec 16, 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
10 changes: 10 additions & 0 deletions contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HEDERA_ACCOUNT_ID=
HEDERA_PRIVATE_KEY=

# testnet / mainnet
HEDERA_ENVIRONMENT=testnet

# dummy ipfs, needs to be replaced with a real one
NFT_METADATA_BASE_URL=ipfs://bafyreie3ichmqul4xa7e6xcy34tylbuq2vf3gnjf7c55trg3b6xyjr4bku/metadata.json


7 changes: 7 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hardhat files
cache/
typechain-types/
artifacts/

# Dependency directories
node_modules/
90 changes: 90 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Contract is work in progress

## What is covered?
- a simple and clean way to create a NFT via smart contract, in the Hedera way.
- as there is no way to send NFT to user wallets during mint (as it's possible in Eth), we are assigning the target wallet id upon mint. Later on, only the assigned wallet will be able to claim the NFT.

## What's needed?
- create BIDI fungible token and lock a certain amount on the NFT, upon minting. The contract will be re-deployed after that's done.

## Deploy the contract
To deploy the project as it is:
- to clear previous contract generations and artifacts ``pnpm run clear``
- to compile a fresh contract ``pnpm run compile``
- before deploying the contract, we have to make sure we added ``NFT_METADATA_URI`` in env variables as future NFT metadata will be saved under that folder. (https://pinata.cloud/ would be a nice place to start..)
- when everything is ready, run ``pnm run deploy`` and the contract will be deployed, and NFT collection created.

Logs after the deployment:
```html
> ts-node scripts/deploy.ts

Client setup complete.

----- Account Information -----
💰 Account Balance:
- 198.56787986 ℏ (HBAR)

----- Deployment Configuration -----
Operator Account: 0.0.4425801
Network: Testnet
Metadata URI: ipfs://bafyreie3ichmqul4xa7e6xcy34tylbuq2vf3gnjf7c55trg3b6xyjr4bku/metadata.json
HashScan Explorer: https://hashscan.io/testnet

----- Reading Contract -----
Contract bytecode size: 10689 bytes

----- Deploying Contract -----
Initiating contract deployment...
Contract deployed successfully!
Contract ID: 0.0.5266745
View Contract: https://hashscan.io/testnet/contract/0.0.5266745

----- Creating NFT Collection -----
Initiating NFT collection creation...
NFT Collection created successfully!
Collection Details:
- Token ID: 0.0.5266746
- Name: Fall Collection
- Symbol: LEAF
- Max Supply: 250
View Token: https://hashscan.io/testnet/token/0.0.5266746

----- Minting NFT -----
Initiating NFT minting...
NFT Minted successfully!
NFT Details:
- Serial Number: 1
- Token ID: 0.0.5266746
- Metadata: ipfs://bafyreie3ichmqul4xa7e6xcy34tylbuq2vf3gnjf7c55trg3b6xyjr4bku/metadata.json
- Allowed Claimer: 000000000000000000000000000000000001e240
View NFT: https://hashscan.io/testnet/token/0.0.5266746/1

----- Deployment Summary -----
Contract ID: 0.0.5266745
Token ID: 0.0.5266746
NFT Serial: 1

```

### Claim logs:

on successful claim:
```html
----- Claiming NFT -----
Initiating claim for NFT #1
NFT claimed successfully!
Claim Details:
- Token ID: 0.0.5266928
- Serial Number: 1
- New Owner: 0.0.4425801
View NFT: https://hashscan.io/testnet/token/0.0.5266928/1

```

if trying to claim a NFT assigned to another wallet
```html
----- Claiming NFT -----
Initiating claim for NFT #1
Error claiming NFT: receipt for transaction [email protected] contained error status CONTRACT_REVERT_EXECUTED

```

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/fdd9c5e1222ec4644fba7d05a6b0a6ea.json"
}
Loading
Loading