0.0.1 âĸ Published 7 months ago
gamechainsdk v0.0.1
đĄī¸ GameChainSDK đšī¸
GameChainSDK is your gateway to seamless integration with blockchain-based game assets. Build, manage, and interact with game assets effortlessly on Ethereum-compatible networks like Sepolia and ANCIENT8.
đ Features
- đ Blockchain Integration: Interact with blockchain game assets using smart contracts.
- đ Easy-to-Use API: Simple functions for registering, transferring, and updating assets.
- đ Multi-Network Support: Works on Sepolia, ANCIENT8, and other EVM-compatible networks.
- đĻ Lightweight and Efficient: Designed for performance and developer productivity.
đĻ Installation
Install via npm:
npm install gamechainsdk
đ Quick Start
Import and Initialize
import GameChainSDK from 'gamechainsdk';
const providerUrl = 'https://rpcv2-testnet.ancient8.gg/';
const contractAddress = '0x8628d91E8311B4856ae7d3E317a0E8fFf48E0f98'; // ANCIENT8 network
const sdk = new GameChainSDK(providerUrl, contractAddress);
đ ī¸ Usage
1ī¸âŖ Register a New Asset
const registerAsset = async () => {
const account = '0xYourAccountAddress'; // Replace with your wallet address
const name = 'Sword of Power';
const metadata = 'A mythical sword of great power.';
try {
const result = await sdk.contract.methods.registerAsset(name, metadata).send({
from: account,
gas: 2000000,
});
console.log('Asset registered successfully:', result);
} catch (error) {
console.error('Error registering asset:', error.message);
}
};
2ī¸âŖ Fetch Owned Assets
const fetchOwnerAssets = async () => {
const account = '0xYourAccountAddress'; // Replace with your wallet address
try {
const assets = await sdk.getOwnerAssets(account);
console.log('Owned assets:', assets);
} catch (error) {
console.error('Error fetching assets:', error.message);
}
};
3ī¸âŖ Update Asset Metadata
const updateAssetMetadata = async () => {
const account = '0xYourAccountAddress';
const assetId = 1; // Replace with the asset ID
const newMetadata = 'Updated description of the sword.';
try {
const result = await sdk.contract.methods.updateAssetMetadata(assetId, newMetadata).send({
from: account,
gas: 2000000,
});
console.log('Metadata updated successfully:', result);
} catch (error) {
console.error('Error updating metadata:', error.message);
}
};
4ī¸âŖ Transfer an Asset
const transferAsset = async () => {
const fromAccount = '0xYourAccountAddress';
const toAccount = '0xRecipientAddress'; // Replace with the recipient's address
const assetId = 1; // Replace with the asset ID
try {
const result = await sdk.contract.methods.transferAsset(assetId, toAccount).send({
from: fromAccount,
gas: 2000000,
});
console.log('Asset transferred successfully:', result);
} catch (error) {
console.error('Error transferring asset:', error.message);
}
};
đ Supported Networks
- đ ī¸ Sepolia Testnet:
0x1d6f8DAAd9a1B9c266768EC1AD0903Ab6E1e89C5
- đŽ ANCIENT8 Network:
0x8628d91E8311B4856ae7d3E317a0E8fFf48E0f98
Make sure your provider URL matches the network of the contract.
âī¸ Advanced Usage
Estimate Gas
Optimize gas usage with estimation:
const gas = await sdk.contract.methods.registerAsset(name, metadata).estimateGas({ from: account });
console.log('Estimated gas:', gas);
đ License
This project is licensed under the MIT License.
đĄ Contributing
Contributions are always welcome! Please fork this repository and submit a pull request for any changes.
đ Support
If you encounter any issues, please open an issue on GitHub or contact the maintainers.
đ Acknowledgements
Thanks to the open-source community and developers who contributed to the creation of GameChainSDK.
đ Author
GameChainSDK is developed and maintained by Sambit Sargam Ekalabya.