Skip to content

Commit e58184b

Browse files
authored
Merge pull request #801 from laviniat1996/base58_decoder
Add `base58` to `hex` deocoder
2 parents f5b6235 + cd489b9 commit e58184b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/evm/base58Decoder.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Serialization } from "../../src/utils"
2+
import { SerializedType } from "../../src/utils"
3+
import { SerializedEncoding } from "../../src/utils"
4+
5+
6+
const base58Decoder = (item: string) => {
7+
const hexVal: string = serialization.decoder(item, base58 , cb58, hex )
8+
return hexVal
9+
}
10+
11+
const cb58: SerializedType = "cb58"
12+
const base58: SerializedEncoding = "base58"
13+
const hex: SerializedType = "hex"
14+
const serialization: Serialization = Serialization.getInstance()
15+
16+
const main = async (): Promise<any> => {
17+
const base58: string = "2MJd1pvSzdvvFKk3aa6qCa4trgnRfjzNfkTCWHha6TxtthsNfd"
18+
19+
const decoded: string = base58Decoder(base58)
20+
console.log("0x" + decoded)
21+
}
22+
23+
main()

0 commit comments

Comments
 (0)