Beispiel #1
0
    public static async void Mint(int tokenEarn, Action updateBalance = null)
    {
        // smart contract method to call
        string method = "mint";
        // address of contract

        // array of arguments for contract
        string args = "[\"0x2aF598ed8104483776661643BCD4995036205760\",\"" + tokenEarn + "\"]";
        // value in wei
        string value = "0";
        // gas limit OPTIONAL
        string gasLimit = "";
        // gas price OPTIONAL
        string gasPrice = "";

        // connects to user's browser wallet (metamask) to update contract state
        try {
            string response = await Web3GL.SendContract(method, abi, smartContract, args, value, gasLimit, gasPrice);

            Debug.Log(response);
            updateBalance?.Invoke();
        } catch (Exception e) {
            Debug.LogException(e);
        }
    }
    async public void OnSendContract()
    {
        // smart contract method to call
        string method = "addTotal";
        // abi in json format
        string abi = "[ { \"inputs\": [ { \"internalType\": \"uint8\", \"name\": \"_myArg\", \"type\": \"uint8\" } ], \"name\": \"addTotal\", \"outputs\": [], \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"inputs\": [], \"name\": \"myTotal\", \"outputs\": [ { \"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\" } ], \"stateMutability\": \"view\", \"type\": \"function\" } ]";
        // address of contract
        string contract = "0x7286Cf0F6E80014ea75Dbc25F545A3be90F4904F";
        // array of arguments for contract
        string args = "[\"1\"]";
        // value in wei
        string value = "0";
        // gas limit OPTIONAL
        string gasLimit = "";
        // gas price OPTIONAL
        string gasPrice = "";

        // connects to user's browser wallet (metamask) to update contract state
        try {
            string response = await Web3GL.SendContract(method, abi, contract, args, value, gasLimit, gasPrice);

            Debug.Log(response);
        } catch (Exception e) {
            Debug.LogException(e, this);
        }
    }
Beispiel #3
0
    async public void OnSignMessage()
    {
        try {
            string message  = "hello";
            string response = await Web3GL.Sign(message);

            Debug.Log(response);
        } catch (Exception e) {
            Debug.LogException(e, this);
        }
    }
Beispiel #4
0
    async public void OnSendTransaction()
    {
        // account to send to
        string to = "0x428066dd8A212104Bc9240dCe3cdeA3D3A0f7979";
        // amount in wei to send
        string value = "12300000000000000";
        // gas limit OPTIONAL
        string gasLimit = "";
        // gas price OPTIONAL
        string gasPrice = "";

        // connects to user's browser wallet (metamask) to send a transaction
        try {
            string response = await Web3GL.SendTransaction(to, value, gasLimit, gasPrice);

            Debug.Log(response);
        } catch (Exception e) {
            Debug.LogException(e, this);
        }
    }
Beispiel #5
0
    async public void SafeTransferFrom()
    {
        // smart contract method to call
        string method = "safeTransferFrom";

        // array of arguments for contract
        string[] obj  = { PlayerPrefs.GetString("Account"), toAccount, tokenId };
        string   args = JsonConvert.SerializeObject(obj);
        // value in wei
        string value = "0";
        // gas limit OPTIONAL
        string gasLimit = "";
        // gas price OPTIONAL
        string gasPrice = "";

        // connects to user's browser wallet (metamask) to send a transaction
        try {
            string response = await Web3GL.SendContract(method, abi, contract, args, value, gasLimit, gasPrice);

            Debug.Log(response);
        } catch (Exception e) {
            Debug.LogException(e, this);
        }
    }