Vaulth smart contracts
Smart contracts of Vaulth project
Running Tests
npx hardhat test
Wrapper
The wrapper is our way to abstract getting informations from vaulth contracts. It uses Ethers.js providers. It consists of 3 classes (ERC721, Certificate, Stamp) that exposes a instance member (the contract functions) and adds additional functions.
Add wrapper to package.jon:
{
"name": "app",
"dependencies": {
"@vaulth/contracts": "github:Vaulth/contracts"
}
}
To update the package to latest main branch commit:
npm install @vaulth/contracts
example:
const chainId = 1;
const provider = new providers.AlchemyProvider(chainId, "api-key");
const NFT = new ERC721(seal.address, provider);
const account = "0x12f7851672034D5f6B7D39f5e4c8992e1F0875B5";
await NFT.getIdsOwned(account);
// => [0, 1, 8]
await NFT.getMintTransaction(0);
// => transaction: {blockNumber: 34, ...}
await NFT.getAllTransactions(0);
// => [transaction]
example of transaction object:
{
blockNumber: 16,
blockHash: '0x9217dcd3ccea8b1a82c60137ecf7f01ab3650cd27112afdf1f136f24d61e9fcd',
transactionIndex: 0,
removed: false,
address: '0x0165878A594ca255338adfa4d48449f69242Eb8F',
data: '0x',
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8',
'0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
'0x0000000000000000000000000000000000000000000000000000000000000000'
],
transactionHash: '0x2d68da5f6120416f32728a835accfdb76b0f91f93675c3f36105c6168f82d192',
logIndex: 1,
removeListener: [Function (anonymous)],
getBlock: [Function (anonymous)],
getTransaction: [Function (anonymous)],
getTransactionReceipt: [Function (anonymous)],
event: 'Transfer',
eventSignature: 'Transfer(address,address,uint256)',
decode: [Function (anonymous)],
args: [
'0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
BigNumber { value: "0" },
from: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
to: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
tokenId: BigNumber { value: "0" }
]
}
📦 ERC 721 Wrapper
getIdsOwned(account):
Returns certificate ids ([int]) owned by the account
getIdsCreated(account):
Returns certificate ids ([int]) created by the account
getAllTransactions(tokenId):
Returns transfer and seal transactions related to tokenId
🖼️ Certificate Wrapper
Inherits ERC721.
getSeals(tokenId):
Returns stamp ids ([int]) which sealed a certificate
getIdsByStampId(stampId):
Returns certificate ids ([int]) sealed by stamp
🏷️ Stamp Wrapper
Inherits ERC721.
🤝 Swap Wrapper
getExchangesIds(account):
Returns exchanges ([int]) opened and related to account (null for all)
getSender(tokenId):
Returns addresses ({from, to}) of open transaction of tokenId