MeetusVR-blockchain-sdk
SDK is divided into multiple services
- Building Service
- Room Service
Buy Building example
const MockUSDT = "0xEe189f1558924f26cba1281E6898B0CCe8b2f657";
const MeetusVRBuilding = "0x53C5dc153acD44274832c0B1eEDf2b1A48358ba1";
const MeetusVRRoom = "0x8f5Eb4A827b0084066D9458e88930608CEC02F6A";
const MeetusVRSale = "0x0f9d4Ca17445CABb0Db1E71Fe6979C4dccB73F51";
const MeetusVRReward = "0x1F106EA0Db7429DFA5CdF2a12389923dEc59e1C7";
const provider = new providers.JsonRpcProvider("RPC_URL");
const wallet = new Wallet("PrivateKey", provider);
const sdk = new MeetusVRBlockchainSDK({
buildingNFTAddress: MeetusVRBuilding,
saleAddress: MeetusVRSale,
rewardAddress: MeetusVRReward,
roomNFTAddress: MeetusVRRoom,
defaultPaymentTokenAddress: MockUSDT,
providerOrSigner: wallet,
});
const tokenSaleData = await api.getTokenSaleData(userAddress);
const { approveAction, isApproved, buyAction } =
sdk.buildingService.buyBuilding({
tokenId: tokenSaleData.tokenId,
paymentToken: tokenSaleData.paymentToken,
price: tokenSaleData.price,
saleType: tokenSaleData.saleType,
signature: tokenSaleData.signature,
deadline: tokenSaleData.deadline,
});
if (!(await isApproved())) {
await approveAction();
}
const result = await buyAction("UserAddress");
Claim Room Reward
const tokenRewardClaims = api.getTokenRewardClaims(userAddress);
const rewardClaim = tokenRewardClaims[0];
const claimRoomResult = await sdk.roomService.claimReward({
user: rewardClaim.user,
amount: rewardClaim.amount,
nonce: rewardClaim.nonce,
token: rewardClaim.token,
tokenId: rewardClaim.tokenId,
tokenStandard: rewardClaim.tokenStandard,
claimMethod: rewardClaim.claimMethod,
signatureTimestamp: rewardClaim.signatureTimestamp,
signatures: rewardClaim.signatures,
deadline: rewardClaim.deadline,
});