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

RPC calling contract parameters are not supported in uint256 format. #442

Open
sjxqqq opened this issue Oct 20, 2023 · 2 comments
Open

RPC calling contract parameters are not supported in uint256 format. #442

sjxqqq opened this issue Oct 20, 2023 · 2 comments

Comments

@sjxqqq
Copy link

sjxqqq commented Oct 20, 2023

I use the code in starknet.go to make rpc call to the remote contract. The contract parameter is uint256. I use the BigIntToFelt, Uint64ToFelt and HexToFelt methods locally for conversion and build the parameter Calldata of rpc.FunctionCall. An error will be reported. How to solve it? The error is as follows:

Internal error: Error in the called contract (0x041e1382e604688da7f22e7fbb6113ba3649b84a87b58f4dc1cf5bfa96dfc2cf):
Error at pc=0:2412:
An ASSERT_EQ instruction failed: 6:2 != 6:1.

The source code is as follows:

package main

import (
	"context"
	"errors"
	"fmt"
	"github.com/NethermindEth/juno/core/felt"
	"github.com/NethermindEth/starknet.go/account"
	"github.com/NethermindEth/starknet.go/utils"
	//	"github.com/NethermindEth/starknet.go/rpc"
	"github.com/NethermindEth/starknet.go/rpc"
)

func OfficeNFTOwnerOf(ctx context.Context, p *rpc.Provider) (string, error) {
	ks := account.NewMemKeystore()
	contractaddr, err := utils.HexToFelt("0x041e1382e604688da7f22e7fbb6113ba3649b84a87b58f4dc1cf5bfa96dfc2cf")
	if err != nil {
		return "", err
	}

	pubKey := "0x043784df59268c02b716e20bf77797bd96c68c2f100b2a634e448c35e3ad363e"
	a, err := account.NewAccount(p, contractaddr, pubKey, ks)
	if err != nil {
		fmt.Println("NewRPCAccount err: ", err)
		return "", err
	}

	tid, err := utils.HexToFelt("0x0107")
	if err != nil {
		fmt.Println("HexToFelt err: ", err)
		return "", err
	}
	//tid := utils.BigIntToFelt(big.NewInt(263))
	//tid := utils.Uint64ToFelt(263)
	qc := rpc.FunctionCall{
		ContractAddress:    contractaddr,
		EntryPointSelector: utils.GetSelectorFromNameFelt("ownerOf"),
		Calldata:           []*felt.Felt{tid},
	}

	res, err := a.Call(ctx, qc, rpc.WithBlockTag("latest"))
	if err != nil {
		fmt.Println("NFTOwnerOf call err: ", err)
		return "", err
	}

	fmt.Println("NFTOwnerOf res  ", res)

	if len(res) > 0 {
		return res[0].String(), nil
	} else {
		fmt.Println("NFTOwnerOf res err  ", res)
		return "", errors.New("res is empty")
	}
}
@cicr99
Copy link
Contributor

cicr99 commented Oct 26, 2023

Hi @sjxqqq , sorry for the late response! We'll be looking into this

@sjxqqq
Copy link
Author

sjxqqq commented Jan 10, 2024

Hi @cicr99 Has this problem been solved?

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