Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Call Get Function #298

Open
sharktap opened this issue Oct 24, 2024 · 2 comments
Open

Error in Call Get Function #298

sharktap opened this issue Oct 24, 2024 · 2 comments

Comments

@sharktap
Copy link

	const provider = new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC');
	const tonweb = new TonWeb(provider);
	const contractAddress = 'EQBdCukjgAO91eFigxNPGRDhW-GqX6PEvzKIR2ouBUL_HFC7';

	function hexToUint8Array(hex) {
		return new Uint8Array(hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
	}

	const code = hexToUint8Array(
		"b5ee9c724102180100033f000114ff00f4a413f4bcf2c80b01020162020702a2d001d0d3030171b0a301fa400120d74981010bbaf2e08820d70b0a208104ffbaf2d0898309baf2e088545053036f04f86102f862db3c5adb3cf2e082c8f84301cc7f01ca005902810101cf00f400c9ed54100301d80192307fe07021d749c21f953020d70b1fde20c00022d749c121b08e1b5b01a4810101f84222103401206e953059f45a30944133f414e27fe08210946a98b6ba8ea7d31f018210946a98b6baf2e081d33f0131c8018210aff90f5758cb1fcb3fc9f84201706ddb3c7fe0307004013a6d6d226eb3995b206ef2d0806f22019132e2102470030480425023db3c0501cac87101ca01500701ca007001ca02500520d74981010bbaf2e08820d70b0a208104ffbaf2d0898309baf2e088cf165003fa027001ca68236eb3917f93246eb3e2973333017001ca00e30d216eb39c7f01ca0001206ef2d08001cc95317001ca00e2c901fb000600987f01ca00c87001ca007001ca00246eb39d7f01ca0004206ef2d0805004cc9634037001ca00e2246eb39d7f01ca0004206ef2d0805004cc9634037001ca00e27001ca00027f01ca0002c958cc020120080d020120090b0211b8d68db3cdb3c6c218100a0002200213bb2b0db3c58db3c6c218100c0026810101220259f40c6fa192306ddf206ef2d0800201200e150201200f140211b6d81b679b678d843010120148ed44d0d401f863d200019a810101d700f404596c12e030f828d70b0a8309baf2e089db3c1100066d7001010ef8276f1079db3c1300da20c10121c24db1f2d086c822c10098802d01cb0702a302de7f706f00048e1b047aa90c20c0005230b0b39b7033a630146f8c04a404039130e204e401b39702802e6f8c02a4de8e10037aa90ca630136f8c03a422c0001034e63322a5039a53126f8101cb0702a502e46c21c9d00095b77a304e0b9d87aba595cf63d09d873ac950a36cd04e13bac6a5a56c8f96645a75e5bfbe2c47304e040ab803700cec7299cb0755c8e4b658704e13b2e9cb5669d96e6741d2cdb28cdd149002014816170011b0afbb5134348000600075b26ee3435697066733a2f2f516d655448536e4b47546f473434444d3232707043326e756361337a697441426e476438326247684739546f4d6f82088c6436f"
	);

class MyContract extends TonWeb.Contract {
constructor(provider, options) {
options.code = code;
super(provider, options);
}

async getPurchaseIndex(param) {
    try {
        const result = await this.provider.callGetMethod(this.address, 'getPurchaseIndex', [param]);
        console.log('Purchase Index:', result);
        return result;
    } catch (error) {
        console.error('getPurchaseIndexの呼び出し中にエラー:', error);
    }
}

}

const contractOptions = {
address: contractAddress,
wc: 0,
};

// カスタムコントラクトのインスタンス作成
const myContract = new MyContract(provider, contractOptions);

// コントラクトの呼び出し
(async () => {
try {

    // 購入インデックスを取得
    const purchaseIndex = await myContract.getPurchaseIndex(1n);
    console.log(`Purchase Index: ${purchaseIndex}`);

} catch (error) {
    console.error('エラーが発生しました:', error);
}
@sharktap
Copy link
Author

Error....please help me. I can't call my contract

@khalilmosavi
Copy link

commented

🔺At first: please follow me and my issues
Now I want you to send me your problem accurately so that I can answer you well.
You can ask your question through my Telegram account:
@skhalilm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants