Nhảy tới nội dung
This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on Crowdin. (Crowdin translation page, Contributing guide)

Units

For units conversion, Kaia-sdk supports utils for converting kaia, Gkei and kei. See supported units .

Import extend from web3py_ext to extend web3 to kaia web3

To convert from (Gkei/kaia) to kei, use Web3.to_kei(value, unit).

To convert from kei to (kaia/Gkei), use Web3.from_kei(value, unit).

unit_utils.py

from web3py_ext import extend
from web3 import Web3
def main():
# convert from (kei/Gkei/kaia) to kei
print("From Kaia to Kei", Web3.to_kei(1, 'Gkei'))
# convert from kei to (kei/Gkei/kaia)
print('From Kei to Kaia',Web3.from_kei(1000000000000000000,'kaia'))
main()

output

❯ py unit_utils.py
From Kaia to Kei 1
From Kei to Kaia 1

Cải thiện trang này