Hashpack / hashconnect

Hashconnect library, readme in progress
BSD Zero Clause License
46 stars 38 forks source link

Signing and Sending Transaction with ContractExecuteTransaction Error #128

Closed mojowlekaz closed 2 years ago

mojowlekaz commented 2 years ago

Here is my Code

async function run() {

let saveData = {
    topic: "",
    pairingString: "",
    privateKey: "",
    pairedWalletData: null,
    pairedAccounts: [],
};
let appMetadata = {
    name: "Hedera dApp Days",
    description: "Let's buidl a dapp on Hedera",
    icon: "https://raw.githubusercontent.com/ed-marquez/hedera-dapp-days/testing/src/assets/hederaLogo.png",
};

let contractId = ContractId.fromString("0.0.47907889"); let accountId = "0.0.47905112" const privateKey = PrivateKey.fromString("302e020100300506032b657004220420341b71552663fe46c2cec11d71dda6a5f804e704760f7e625ba59165a56d1a59");

let hashconnect = new HashConnect();

const provider = hashconnect.getProvider('testnet', saveData.topic, accountId) const signer = hashconnect.getSigner(provider) let balance = await provider.getAccountBalance(accountId) const stakeTx = await new ContractExecuteTransaction() .setContractId(contractId) .setGas(500000) .setPayableAmount(50) .setFunction("stakeTokens") .freezeWithSigner(signer); const result = await stakeTx.executeWithSigner(signer) console.log(result)

} when i run this, it gives me an error "Error: SimpleCrypto object MUST BE initialised with a SECRET KEY."

teacoat commented 2 years ago

You are not initializing hashconnect - please read docs

mojowlekaz commented 2 years ago

I did initialise Hashconnect

You can send me a link to that if I'm getting something wrong.

On Sat, 20 Aug 2022, 3:08 pm Tyler Cote, @.***> wrote:

You are not initializing hashconnect - please read docs

— Reply to this email directly, view it on GitHub https://github.com/Hashpack/hashconnect/issues/128#issuecomment-1221321361, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWGVSZLJ6QHD67KN2CT2Z6LV2DREHANCNFSM57DBLOQA . You are receiving this because you authored the thread.Message ID: @.***>

teacoat commented 2 years ago

You are literally not calling .init()

mojowlekaz commented 2 years ago

Oh..

I did that and I'm not sure what the error is about, could you show me how it'll be written properly?

On Sat, 20 Aug 2022, 3:12 pm Tyler Cote, @.***> wrote:

You are literally not calling .init()

— Reply to this email directly, view it on GitHub https://github.com/Hashpack/hashconnect/issues/128#issuecomment-1221322030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWGVSZPMDVX7BSSXWT2ARW3V2DRURANCNFSM57DBLOQA . You are receiving this because you authored the thread.Message ID: @.***>

teacoat commented 2 years ago

read the docs

steffanjensen commented 2 years ago

read the docs

Top the worst response I have ever seen on github..

great job

teacoat commented 2 years ago

great job

Thank you

steffanjensen commented 2 years ago

Fixed it by following the examples: https://github.com/Hashpack/hashconnect/tree/main/example/dapp

Still the documentation is lacking.