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 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);
        }
    }