Conflux-Chain / ConfluxWeb

Conflux JavaScript API, under active development
GNU Lesser General Public License v3.0
7 stars 5 forks source link

BN and await Not wokring #1

Closed saarshah closed 4 years ago

saarshah commented 4 years ago

I have followed this tutorial , following command give error

await contract.deploy({arguments: [254]}).send({
    from: '0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b',
    gas: 100000000,
    gasPrice: 819
 }); // deploy contract by `send`

Error: SyntaxError: await is only valid in async function

const bn = new BN(10) gives error, ReferenceError: BN is not defined

liuis commented 4 years ago

@saarshah ,Async () function returns the object is a Promise, so can't use the outermost layers in await get its return value, you should use the original way, then () chain to deal with this Promise。