#Transaction Status of a particular transaction

1 messages · Page 1 of 1 (latest)

tawny crest
#

How to get the status of a transaction?

I am using the following code to transfer ERC20.

public async void TransferErc20()
    {
        var mintResponse = await Web3Accessor.Web3.Erc20.Transfer(contractAddress, toAccount, amountTransfer);
        var output = SampleOutputUtil.BuildOutputValue(mintResponse);
        SampleOutputUtil.PrintResult(output, "ERC-20", nameof(Erc20Service.Transfer));
        // You can make additional changes after this line
    }

Now how to get the particular transaction status?
Which transaction's status the following code will give ?

public async void GetTransactionStatusCall()
    {
        var receipt = await Evm.GetTransactionStatus(Web3Accessor.Web3);
        var output = $"Confirmations: {receipt.Confirmations}," +
                     $" Block Number: {receipt.BlockNumber}," +
                     $" Status {receipt.Status}";

        SampleOutputUtil.PrintResult(output, nameof(Evm), nameof(Evm.GetTransactionStatus));
        // You can make additional changes after this line
    }
hybrid light
#

should give you transaction status of the last tx the instance used/is using

tawny crest
#

After transaction on cardona chain getting the following error and not getting transaction status
**
Web3Exception: HTTP.POST to https://rpc.walletconnect.com/v1?chainId=eip155:2442&projectId=f4bff60eb260841f46b1c77588cd8acb responded with error: {"status":"FAILED","reasons":[{"field":"chainId","description":"We don't support the chainId you provided: eip155:2442. See the list of supported chains here: https://docs.walletconnect.com/cloud/blockchain-api#supported-chains"}]}
ChainSafe.Gaming.Web3.Core.Unity.UnityHttpClient.UnityWebRequestToNetworkResponse (UnityEngine.Networking.UnityWebRequest request) (at <192da10ac46144d1b6e1301f9df433a4>:0)
ChainSafe.Gaming.Web3.Core.Unity.UnityHttpClient+<>c__DisplayClass4_0.<PostRaw>b__0 () (at <192da10ac46144d1b6e1301f9df433a4>:0)
ChainSafe.Gaming.Evm.Unity.Dispatcher+<>c__DisplayClass12_0`1[T].<EnqueueTask>g__WrappedAction|0 ()
ChainSafe.Gaming.WalletConnect.WalletConnectProvider.Request[T] (System.String method, System.Object[] parameters)
ChainSafe.Gaming.WalletConnect.WalletConnectProvider.WalletConnectRequest[T] (System.String topic, System.String method, System.String chainId, System.Object[] parameters)
Rethrow as WalletConnectException: eth_getTransactionByHash RPC method currently not implemented.
ChainSafe.Gaming.WalletConnect.WalletConnectProvider.WalletConnectRequest[T] (System.String topic, System.String method, System.String chainId, System.Object[] parameters)
**

The Blockchain API is the RPC service that powers AppKit's blockchain functions such as account balances, ENS resolution, transaction history, and more.

tawny crest
#

And when calling GetTransactionStatus(), then player needs to confirm on wallet, but getting the same error.

hybrid light
#

"field":"chainId","description":"We don't support the chainId you provided: eip155:2442

tawny crest
#

I have tried Aurora Testnet.
And getting the following error while trying to get transaction status

WalletConnectException: RPC method eth_blockNumber is not supported. If you add a new method you have to update WalletConnectProvider code to reflect those changes. Contact ChainSafe if you think a specific method should be included in the SDK.

tawny crest
#

I have tried on multiple testnet, but not getting transaction status.

I haven't tried yet on mainnet. Please give me code so that I can get transaction is success or not as bool.

I want something like the following

public async void TransferErc20()
    {
        var response = await Web3Accessor.Web3.Erc20.Transfer(contractAddress, toAccount, amountTransfer);

bool success = // some code from response to Boolean 


if (success)
{
// then do something 
}
else
{
// Do something
}
}
        
        

Please help me!!

hybrid light
#

if we look at the function we can see it's returning receipt.Status, if we dive into the receipt type declaration, we can see the status is of type hexbigint. This is a hexadecimal representation of a boolean where 0x1 means true and 0x0 means false. If you want to do an if else like that you need to convert it using a helper method and compare against it, something like this:

#
public class GetTransactionStatus : MonoBehaviour
{
    // Function
    public async void GetTransactionStatusCall()
    {
        var receipt = await Evm.GetTransactionStatus(Web3Accessor.Web3);
        var output = $"Confirmations: {receipt.Confirmations}," +
                     $" Block Number: {receipt.BlockNumber}," +
                     $" Status: {receipt.Status}";
        SampleOutputUtil.PrintResult(output, nameof(Evm), nameof(Evm.GetTransactionStatus));
        
        bool isSuccess = ConvertHexBigIntegerToBool(receipt.Status);
        if (isSuccess)
        {
            Debug.Log("Transaction was successful.");
        }
        else
        {
            Debug.Log("Transaction failed.");
        }
    }

    private bool ConvertHexBigIntegerToBool(HexBigInteger hexValue)
    {
        return hexValue.Value != 0;
    }
}
tawny crest
tacit canyon
# tawny crest Thank you very much!! I can't test transaction status on testnet, there is some ...

If the network is on Chainlist: https://chainlist.org/
and it's on Wallet Connect's supported chain list: https://docs.walletconnect.com/cloud/chains/chain-list, then you shouldn't be running into issues.

I checked Aurora testnet and it's on both. Maybe try uninstalling and reinstalling the packages.

Generally, I would never move to mainnet before testing on testnet.

tawny crest
tawny crest
#

I am using the following code to transfer custom ERC20 token

var transferResponse = await Web3Accessor.Web3.Erc20.Transfer(contractAddress, toAccount, amountTransfer); Debug.Log("Transfer Response :  "+transferResponse");

The transfer is being successful, but not getting the response.

When the transaction is completed getting the following Logs :

[Web3] [WalletConnect SDK] Got generic response for type System.String
[Web3] [WalletConnect SDK] Transaction executed successfully. Hash: 0x06f0a9d2058d043dbcf35aea7c7d680b846db777c1cf38c8aa8279a042544f33.
(The error) WalletConnectException: RPC method eth_blockNumber is not supported. If you add a new method you have to update WalletConnectProvider code to reflect those changes. Contact ChainSafe if you think a specific method should be included in the SDK.
So in the above code the following line is not being invoked/executed
Debug.Log("Transfer Response : "+transferResponse");

graceful ivy
#

does your wallet support that chain?

tawny crest
tawny crest
# graceful ivy does your wallet support that chain?

Tried on multiple testnet like Sepolia, Aurora, Amoy which are supported by WalletConnect as well as on Chainsafe Server settings. And also added on my Wallet. But result is same.
Transaction is successful, but getting the above error before getting the response.

tawny crest
graceful ivy
#

Can you provide me with the following: Contract address, contract ABI, amount transfer

#

everything.

#

We have potential fix in dev for the transactions not being executed properly, but will be on main only in a month due to us packing a new release.

#

How can I repro the steps myself

#

with you giving me the exact repro steps (what chain are you on, and things I've mentioned above) should help me out in debugging the issue . Without it I can't do much

tawny crest
#

Contract Address
0x24383f6AC03b6B43ae95CFb83C88762Af1e142E8

#

Transferring Amount is 1

#

Project Config :
projectID: cd4c1f93-3cab-4d36-ade1-3ec3fa410a8f
chainID: 11155111
chain: Sepolia
network: ETH
symbol: ETH
rpc: https://rpc.sepolia.org

#

The Contract is deployed on the above chain.
Using Metamask to connect. Metamask also has Sepolia network even with same RPC.

tawny crest
# graceful ivy with you giving me the _exact_ repro steps (what chain are you on, and things I'...

Reproduce steps :

  1. Connecting wallet With QR scan on Unity Editor, (2022.3.15f1)
  2. Then trying to transfer using the following code. The transfer will be successful, getting TxHash. Receiver getting the Token.
  3. Console shows an error.
var transferResponse = await Web3Accessor.Web3.Erc20.Transfer(contractAddress, toAccount, amountTransfer); 
Debug.Log("Transfer Response :  "+transferResponse");

But control is not coming back to the Actual function from where the method Web3Accessor.Web3.Erc20.Transfer was called. So not returning transferResponse and the line Debug.Log("Transfer Response : "+transferResponse"); is not being executed,

Getting some error between Showing Transaction Hash and returning response.

#

My wallet address is 0xB65f5Ac5eAD9598f7Ec61c8C89033B970dA7B77D

#

On this wallet I have more than 900 tokens and Sepolia Faucet

#

This same error is being shown while calling GetTransactionStatus

tawny crest
graceful ivy
#

It's not a custom token right? but classic eth? That's good to know, testing it out on main.

tawny crest
graceful ivy
#

can you send me some of that token trough MM directly? so without using the SDK

#

0xb4aa2EAdd382Def28d20a7d12966FA64b768e56F

#

this is my MM address.

tawny crest
#

I have sent you 100 tokens

#

Actual amount
0.000000000000000100

graceful ivy
#

how much should I put in transfer, just 1?

tawny crest
#

Yes

graceful ivy
#

cool ty

tawny crest
#

If I transfer using Chainsafe then, transferring just 1 will work.
But to send from MM, need to put

0.000000000000000001

graceful ivy
#

Hey @tawny crest can you now update the unity package ? The fix should be up.

tawny crest
graceful ivy
#

where did you download it from?

#

git or openUPM/

#

I'd recommend git tbh

#

since we are not publishing these hotifxes to openUPM

tawny crest
#

Unity package manager using git url

tawny crest
#

Shall I download .unitypackage from GitHub and import in project?

graceful ivy
#

No no

#

Thats good

#

How you have done it is good

#

Just click on update

tawny crest
#

Are you not getting any error?

#

I checked in an empty project yesterday with updated sdk

graceful ivy
#

but sdk got updated like 8 mins ago on main 😄

#

let me check on an empty proj

#

Yeah on an empty project not getting any error/compiler error when importing the fresh project.

tawny crest
#

Just problem with transfer response
And GetTransactionStatus method

graceful ivy
#

please re-import the package asstated above. we have updated it 10 minutes ago on main. Thank you.

tawny crest
graceful ivy
#

well you need to in order for you issue to be fixed 🙂

tawny crest
tawny crest
#

After updating, no error to get response.
But transferResponse[0] is showing as false.

And if we call GetTransactionStatus(), it needs confirmation from the wallet and again needs gas fee.

tawny crest
graceful ivy
#

Yes you can but that requires a bit more lines to be written:
Instead of calling Web3Acessor.Web3.Erc20.Transfer();
You should call var res= await Web3Accessor.Web3.Erc20.BuildContract("yourAddress").SendWithReceipt("transfer", new object[] {to, amount})
result would have the response object and the reciept as a tuple.
SO you can call it like res.receipt.TransactionHash or if you need the transaction status res.receipt.Status. iF status is 1 , that means transaction went trough. 🙂

#

in the upcoming verison of the SDK we'll have ABI To C# contract generator where you could've simply just create your custom contract and do the following:

var contract = Web3Accessor.Web3.ContractBuilder.Build<CustomContract>(contractAddress);
var res = await contract.TransferWithReciept(to, amount);

tawny crest
#

Yes that's working.
Thank you very much !!

graceful ivy