-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ava-labs/port-to-typescript
v0.1.1-rc
- Loading branch information
Showing
14 changed files
with
258 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//SPDX-License-Identifier: mit | ||
pragma solidity >= 0.6.2 < 0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract ExampleERC20 is ERC20, Ownable { | ||
string private TOKEN_NAME = "Example ERC20 Token"; | ||
string private TOKEN_SYMBOL = "XMPL"; | ||
|
||
uint private constant TOTAL_SUPPLY = 123456789; | ||
|
||
constructor() ERC20(TOKEN_NAME, TOKEN_SYMBOL) { | ||
_mint(msg.sender, TOTAL_SUPPLY); | ||
} | ||
|
||
function mint(address to, uint256 amount) public onlyOwner() { | ||
_mint(to, amount); | ||
} | ||
|
||
function burn(address from, uint256 amount) public onlyOwner() { | ||
_burn(from, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
// contracts/ERC721.sol | ||
// spdx-license-identifier: mit | ||
|
||
pragma solidity >= 0.6.2; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
|
||
contract GameItem is ERC721 { | ||
using Counters for Counters.Counter; | ||
Counters.Counter private _tokenIds; | ||
using Counters for Counters.Counter; | ||
Counters.Counter private _tokenIds; | ||
|
||
constructor() ERC721("GameItem", "ITM") {} | ||
constructor() ERC721("GameItem", "ITM") {} | ||
|
||
function awardItem(address player, string memory tokenURI) | ||
public | ||
returns (uint256) | ||
{ | ||
_tokenIds.increment(); | ||
function awardItem(address player, string memory tokenURI) public returns (uint256) { | ||
_tokenIds.increment(); | ||
|
||
uint256 newItemId = _tokenIds.current(); | ||
_mint(player, newItemId); | ||
_setTokenURI(newItemId, tokenURI); | ||
uint256 newItemId = _tokenIds.current(); | ||
_mint(player, newItemId); | ||
// _setTokenURI(newItemId, tokenURI); | ||
|
||
return newItemId; | ||
} | ||
return newItemId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//SPDX-License-Identifier: mit | ||
pragma solidity ^0.8.0; | ||
|
||
contract Storage { | ||
uint256 number; | ||
|
||
function store(uint256 num) public { | ||
number = num; | ||
} | ||
|
||
function retrieve() public view returns (uint256) { | ||
return number; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
Contract, | ||
ContractFactory | ||
} from "ethers" | ||
import { ethers } from "hardhat" | ||
|
||
const main = async(): Promise<any> => { | ||
const Coin: ContractFactory = await ethers.getContractFactory("ExampleERC20") | ||
const coin: Contract = await Coin.deploy() | ||
|
||
await coin.deployed() | ||
console.log(`Coin deployed to: ${coin.address}`) | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
BigNumber, | ||
Contract | ||
} from "ethers" | ||
import { ethers } from "hardhat" | ||
|
||
const coinName: string = "" | ||
const coinAddr: string = "" | ||
const walletAddress: string = "" | ||
|
||
const main = async (): Promise<any> => { | ||
const contract: Contract = await ethers.getContractAt(coinName, coinAddr) | ||
const contractAddress: string = contract.address | ||
console.log(`Address: ${contractAddress}`) | ||
|
||
const name: string = await contract.name() | ||
console.log(`Name: ${name}`) | ||
|
||
const symbol: string = await contract.symbol() | ||
console.log(`Symbol: ${symbol}`) | ||
|
||
const decimals: string = await contract.decimals() | ||
console.log(`Decimals: ${decimals}`) | ||
|
||
const balance: BigNumber = await contract.balanceOf(walletAddress) | ||
console.log(`Balance of ${walletAddress}: ${balance.toString()}`) | ||
|
||
let totalSupply: BigNumber = await contract.totalSupply() | ||
console.log(`Total supply: ${totalSupply.toString()}`) | ||
|
||
console.log(`-----MINTING-----`) | ||
await contract.mint(walletAddress, totalSupply) | ||
|
||
totalSupply = await contract.totalSupply() | ||
console.log(`Total supply: ${totalSupply.toString()}`) | ||
|
||
console.log(`-----BURNING-----`) | ||
await contract.burn(walletAddress, totalSupply) | ||
|
||
totalSupply = await contract.totalSupply() | ||
console.log(`Total supply: ${totalSupply.toString()}`) | ||
|
||
const tx = await contract.transfer(walletAddress, balance) | ||
console.log("--TX--") | ||
console.log(tx) | ||
|
||
const txReceipt = await tx.wait() | ||
console.log("--TX RECEIPT--") | ||
console.log(txReceipt) | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
Oops, something went wrong.