StarkMoba is an server authoritative and both server & client side optimized MOBA Game Template.
You can use StarkSharp to connect MOBA game to Starknet. If you want to learn how to install it, check StarkSharp Installation on Unity.
Example Connection:
- Create a new platform
Platform myNewPlatform = UnityPlatform.New(PlatformConnectorType.Sharpion);
- Create a new connector and add your platform to the connector
Connector connector = new Connector(myNewPlatform);
- Connect Wallet
- ArgentX
connector.ConnectWallet(WalletType.ArgentX,
(successMessage) => OnWalletConnectionSuccess(successMessage),
(errorMessage) => OnWalletConnectionError(errorMessage));
- Braavos
connector.ConnectWallet(WalletType.Braavos,
(successMessage) => OnWalletConnectionSuccess(successMessage),
(errorMessage) => OnWalletConnectionError(errorMessage));
- Create Actions
public void OnWalletConnectionSuccess(string message)
{
connector.DebugMessage("On Wallet Connection Success: " + message);
}
public void OnWalletConnectionError(string message)
{
connector.DebugMessage("On Wallet Connection Error: " + message);
}
- Send Transaction
connector.SendTransaction(
ERC20Standart.TransferToken(sendTransactionContractAddress, sendTransactionRecipientAddress, amount),
(successMessage) => OnSendTransactionSuccess(successMessage),
(errorMessage) => OnSendTransactionError(errorMessage));
- If you are wondering how to send a custom transaction, here is how you can do it:
ContractInteraction myContractInteraction = new ContractInteraction(_ContractAdress, _EntryPoint, _CallData);
connector.SendTransaction(
myContractInteraction,
(successMessage) => OnSendTransactionSuccess(successMessage),
(errorMessage) => OnSendTransactionError(errorMessage));
- Call Contract
- You need to use RPC Platform for Call Contract. In order to do this, create a new connector.
Platform myNewPlatform = UnityPlatform.New(PlatformConnectorType.RPC);
connector.CallContract(
ERC20Standart.BalanceOf(callContractContractAddress, callOtherUserWalletAddress),
(successMessage) => OnCallContractSuccess(successMessage),
(errorMessage) => OnCallContractError(errorMessage));
- If you want to send a custom query, here is the code:
ContractInteraction myContractInteraction = new ContractInteraction(_ContractAdress, _EntryPoint, _CallData);
connector.CallContract(
myContractInteraction,
(successMessage) => OnCallContractSuccess(successMessage),
(errorMessage) => OnCallContractError(errorMessage)
);
Thanks to these amazing people for their contributions.
lastceri Developer |
sektor7k Developer |
cannsky Developer |