나는 이것을 시도하고있다 :
import { BN } from 'web3-utils'
const AmountBN = new BN('1000000000000000000')
const res = AmountBN.mul(99).div(100)
console.log(res)
그리고 이것을 얻으십시오
Uncaught (in promise) RangeError: Invalid array length
at BN.mul (bn.js:1862)
그것은 다소 융통성이지만, mul()
및 div()
또한 매개 변수가 아닌 숫자로 BN을 기대합니다. 그리고 결과는 BN
다시 사용toString()
따라서 다음과 같이 작성해야합니다.
const res = AmountBN.mul(new BN('99')).div(new BN('100'))
console.log(res.toString())
도움이 되었기를 바랍니다
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다