Skip to content

Commit 5742cf8

Browse files
committed
Phantom support via MetaMaskWallet
1 parent ce9935b commit 5742cf8

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

Assets/Thirdweb/Runtime/Unity/Wallets/Core/MetaMaskWallet.cs

+26-13
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,32 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
117117
Method = "eth_sendTransaction",
118118
Params = new object[]
119119
{
120-
new TransactionInput()
121-
{
122-
Nonce = transaction.Nonce,
123-
From = await GetAddress(),
124-
To = transaction.To,
125-
Gas = transaction.Gas,
126-
GasPrice = transaction.GasPrice,
127-
Value = transaction.Value,
128-
Data = transaction.Data,
129-
MaxFeePerGas = transaction.MaxFeePerGas,
130-
MaxPriorityFeePerGas = transaction.MaxPriorityFeePerGas,
131-
ChainId = new HexBigInteger(WebGLMetaMask.Instance.GetActiveChainId()),
132-
}
120+
transaction.GasPrice == null
121+
? new
122+
{
123+
nonce = transaction.Nonce.HexValue,
124+
from = await GetAddress(),
125+
to = transaction.To,
126+
gas = transaction.Gas.HexValue,
127+
value = transaction.Value?.HexValue ?? "0x0",
128+
data = transaction.Data,
129+
maxFeePerGas = transaction.MaxFeePerGas.HexValue,
130+
maxPriorityFeePerGas = transaction.MaxPriorityFeePerGas?.HexValue ?? "0x0",
131+
chainId = WebGLMetaMask.Instance.GetActiveChainId().NumberToHex(),
132+
type = "0x2"
133+
}
134+
: new
135+
{
136+
nonce = transaction.Nonce.HexValue,
137+
from = await GetAddress(),
138+
to = transaction.To,
139+
gas = transaction.Gas.HexValue,
140+
value = transaction.Value?.HexValue ?? "0x0",
141+
data = transaction.Data,
142+
gasPrice = transaction.GasPrice.HexValue,
143+
chainId = WebGLMetaMask.Instance.GetActiveChainId().NumberToHex(),
144+
type = "0x0"
145+
}
133146
}
134147
};
135148
return await WebGLMetaMask.Instance.RequestAsync<string>(rpcRequest);

0 commit comments

Comments
 (0)