How to use the tronweb.utils function in tronweb

To help you get started, we’ve selected a few tronweb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tronscan / tronscan-frontend / src / utils / contractUtils.js View on Github external
decodeParams(message, abiCode, function_selector) {
        const cutArr = function_selector.match(/(.+)\((.*)\)/);
        console.log('abiCode', abiCode)
        if (cutArr[2] !== '') {
            const byteArray = TronWeb.utils.code.hexStr2byteArray(message);
            const abi = abiCode.filter(({
                name
            }) => name === cutArr[1]);
            return abi[0].inputs.map(({
                name,
                type
            }, i) => {
                let value;
                const array = byteArray.filter((v, index) => index >= 32 * i && index < 32 * (i + 1));
                if (type === 'address') {
                    value = TronWeb.address.fromHex('41' + TronWeb.utils.code.byteArray2hexStr(array.filter((v, i) => i > 11)));
                } else if (type === 'trcToken') {
                    value = TronWeb.toDecimal('0x' + TronWeb.utils.code.byteArray2hexStr(array));
                } else {
                    value = TronWeb.toDecimal('0x' + TronWeb.utils.code.byteArray2hexStr(array));
                }
github TronLink / tronlink-extension / packages / lib / utils.js View on Github external
return abi[0].inputs.map(({name,type},i)=>{
                let value;
                const array = byteArray.filter((v,index)=>index >=32 * i && index< 32 * (i + 1));
                if(type === 'address') {
                    value = TronWeb.address.fromHex('41'+TronWeb.utils.code.byteArray2hexStr(array.filter((v,i) => i>11)));
                } else if(type === 'trcToken') {
                    value = TronWeb.toDecimal('0x'+TronWeb.utils.code.byteArray2hexStr(array));
                } else {
                    value = TronWeb.toDecimal('0x'+TronWeb.utils.code.byteArray2hexStr(array));
                }
                return {name,type,value};
            });
        }else{
github TronLink / tronlink-extension / packages / lib / utils.js View on Github external
decodeParams(message,abiCode,function_selector) {
        const cutArr = function_selector.match(/(.+)\((.*)\)/);
        if(cutArr[2]!==''){
            const byteArray = TronWeb.utils.code.hexStr2byteArray(message);
            const abi = abiCode.filter(({name})=> name === cutArr[1]);
            return abi[0].inputs.map(({name,type},i)=>{
                let value;
                const array = byteArray.filter((v,index)=>index >=32 * i && index< 32 * (i + 1));
                if(type === 'address') {
                    value = TronWeb.address.fromHex('41'+TronWeb.utils.code.byteArray2hexStr(array.filter((v,i) => i>11)));
                } else if(type === 'trcToken') {
                    value = TronWeb.toDecimal('0x'+TronWeb.utils.code.byteArray2hexStr(array));
                } else {
                    value = TronWeb.toDecimal('0x'+TronWeb.utils.code.byteArray2hexStr(array));
                }
                return {name,type,value};
            });
        }else{
            return [];
        }
github tronscan / tronscan-frontend / src / utils / contractUtils.js View on Github external
return abi[0].inputs.map(({
                name,
                type
            }, i) => {
                let value;
                const array = byteArray.filter((v, index) => index >= 32 * i && index < 32 * (i + 1));
                if (type === 'address') {
                    value = TronWeb.address.fromHex('41' + TronWeb.utils.code.byteArray2hexStr(array.filter((v, i) => i > 11)));
                } else if (type === 'trcToken') {
                    value = TronWeb.toDecimal('0x' + TronWeb.utils.code.byteArray2hexStr(array));
                } else {
                    value = TronWeb.toDecimal('0x' + TronWeb.utils.code.byteArray2hexStr(array));
                }
                return {
                    name,
                    type,
                    value
                };
            });
        } else {

tronweb

JavaScript SDK that encapsulates the TRON HTTP API

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis