How to create signature as an input for type Vec<u8> on smart contract

73 views Asked by At

I'm trying to create a signature for my function in smart contract but it return "invalid type: map, expected a sequence" error.

Here is the code:

    async function onSign() {
        const nearConfig = getConfig('development')
        // Initialize connection to the NEAR testnet
        const near = await connect(Object.assign({ deps: { keyStore: new keyStores.BrowserLocalStorageKeyStore() } }, nearConfig))
        window.near = near
        // Initializing Wallet based Account. It can work with NEAR testnet wallet that
        // is hosted at https://wallet.testnet.near.org
        window.walletConnection = new WalletConnection(near)

        // Getting the Account ID. If still unauthorized, it's just empty string
        window.accountId = window.walletConnection.account()

        let account = window.accountId;
        const realSigner = account.connection.signer

        let key2 = await realSigner.keyStore.getKey(account.connection.networkId, account.accountId)

        let mess = 'zxczxvzvx';
        let encodedMess = str2ab(mess);

        let signature = await key2.sign(encodedMess);
        console.log(signature);

        let a = await wallet.callMethod({
            contractId: "dev-1668740733204-48404403176628", 
            method: "ft_transfer_call", 
            args: {
                "receiver_id": "dev-1669022432132-58804567266197",
                "amount": "0",
                "memo": "None",
                "msg": "create_room",
                "_advisor": "dev-1669018198583-29903555965521",
                "_amount_per_minute": "1",
                "_room_id": "1",
                "_minutes_lasts": 5,
                "_signature": Buffer.from(signature.signature, 'hex'),
                "_signer": "tungleanh.testnet",
            }
        })
    }

Here is the parameters on smart contract: &mut self, receiver_id: AccountId, amount: U128, memo: Option, msg: String, _advisor: Option, _amount_per_minute: Option, _room_id: Option, _minutes_lasts: Option, _signature: Option<Vec>, _signer: Option<Vec>,

How can I fix this?

0

There are 0 answers