-
Discord user IDchineseculture Describe your question in detail.import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const config = new AptosConfig({ network: Network.MAINNET });
const aptos = new Aptos(config);
async function checkPoolExists() {
try {
const result = await aptos.view({
payload: {
function: '0x4bf51972879e3b95c4781a5cdcb9e1ee24ef483e7d22f2d903626f126df62bd1::liquidity_pool::liquidity_pool',
functionArguments: [
"0x01::aptos_coin::AptosCoin",
"0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
"false"
],
}
})
console.log('池子是否存在:', result)
return result
} catch (error) {
console.error('检查池子时出错:', error)
return false
}
}
checkPoolExists() {
"name": "liquidity_pool",
"visibility": "public",
"is_entry": false,
"is_view": true,
"generic_type_params": [],
"params": [
"0x1::object::Object<0x1::fungible_asset::Metadata>",
"0x1::object::Object<0x1::fungible_asset::Metadata>",
"bool"
],
"return": [
"0x1::object::Object<0x4bf51972879e3b95c4781a5cdcb9e1ee24ef483e7d22f2d903626f126df62bd1::liquidity_pool::LiquidityPool>"
]
} I tried to use the SDK's view to get apt and whether a certain token has a liquidity pool established. The above are my code and the contract's abi, but I got an error. The error is as follows. Is the parameter I passed in incorrect?
What error, if any, are you getting?
What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?macOS Which SDK or tool are you using? (if any)TypeScript SDK Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @wocaatm , looking at the contract on the Explorer the first 2 arguments are of type The This should work:
|
Beta Was this translation helpful? Give feedback.
Hey @wocaatm , looking at the contract on the Explorer the first 2 arguments are of type
Object
which mean the input should be anaddress
.The
AptosCoin
FA address is0xa
, BUT because you are trying to useCellana Finance
contract, they use a different AptosCoin FA address which is0xedc2704f2cef417a06d1756a04a16a9fa6faaed13af469be9cdfcac5a21a8e2e
.This should work: