UNPKG

@tatumio/tatum-v1

Version:

Tatum API client allows browsers and Node.js clients to interact with Tatum API.

693 lines 119 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.sendKlaytnBurnMultiTokenBatchSignedTransaction = exports.sendKlaytnBurnMultiTokenSignedTransaction = exports.sendKlaytnDeployErc721SignedTransaction = exports.sendKlaytnUpdateCashbackForAuthorErc721SignedTransaction = exports.sendKlaytnTransferErc721SignedTransaction = exports.sendKlaytnBurnErc721SignedTransaction = exports.sendKlaytnMintMultipleErc721SignedTransaction = exports.sendKlaytnMintMultipleErc721ProvenanceSignedTransaction = exports.sendKlaytnMintMultipleCashbackErc721SignedTransaction = exports.sendKlaytnMintErc721ProvenanceSignedTransaction = exports.sendKlaytnMintCashbackErc721SignedTransaction = exports.sendKlaytnMintErc721SignedTransaction = exports.sendKlaytnDeployErc20SignedTransaction = exports.sendKlaytnTransferErc20SignedTransaction = exports.sendKlaytnBurnErc20SignedTransaction = exports.sendKlaytnMintErc20SignedTransaction = exports.sendKlaytnStoreDataTransaction = exports.sendKlaytnSmartContractReadMethodInvocationTransaction = exports.prepareKlaytnSmartContractWriteMethodInvocation = exports.prepareKlaytnDeployMultiTokenSignedTransaction = exports.prepareKlaytnMintMultiTokenBatchSignedTransaction = exports.prepareKlaytnMintMultiTokenSignedTransaction = exports.prepareKlaytnBatchTransferMultiTokenSignedTransaction = exports.prepareKlaytnTransferMultiTokenSignedTransaction = exports.prepareKlaytnBurnMultiTokenBatchSignedTransaction = exports.prepareKlaytnBurnMultiTokenSignedTransaction = exports.prepareKlaytnDeployAuctionSignedTransaction = exports.prepareKlaytnDeployMarketplaceListingSignedTransaction = exports.prepareKlaytnDeployErc721SignedTransaction = exports.prepareKlaytnUpdateCashbackForAuthorErc721SignedTransaction = exports.prepareKlaytnTransferErc721SignedTransaction = exports.prepareKlaytnBurnErc721SignedTransaction = exports.prepareKlaytnMintMultipleErc721SignedTransaction = exports.prepareKlaytnMintMultipleCashbackErc721SignedTransaction = exports.prepareKlaytnMintMultipleErc721ProvenanceSignedTransaction = exports.prepareKlaytnMintCashbackErc721SignedTransaction = exports.prepareKlaytnMintErc721ProvenanceSignedTransaction = exports.prepareKlaytnMintErc721SignedTransaction = exports.prepareKlaytnDeployErc20SignedTransaction = exports.prepareKlaytnTransferErc20SignedTransaction = exports.prepareKlaytnBurnErc20SignedTransaction = exports.prepareKlaytnMintErc20SignedTransaction = exports.prepareKlaytnStoreDataTransaction = exports.prepareKlaytnSignedTransaction = exports.prepareKlaytnGenerateCustodialWalletSignedTransaction = exports.getKlayErc20ContractDecimals = exports.signKlayKMSTransaction = exports.prepareKlaytnClient = exports.sendKlaytnTransaction = exports.klayGetGasPriceInWei = void 0; exports.sendKlaytnDeployMarketplaceListingSignedTransaction = exports.sendKlaytnSmartContractMethodInvocationTransaction = exports.sendKlaytnGenerateCustodialWalletSignedTransaction = exports.sendKlaytnDeployMultiTokenSignedTransaction = exports.sendKlaytnMintMultiTokenBatchSignedTransaction = exports.sendKlaytnMintMultiTokenSignedTransaction = exports.sendKlaytnBatchTransferMultiTokenSignedTransaction = exports.sendKlaytnTransferMultiTokenSignedTransaction = void 0; const bignumber_js_1 = require("bignumber.js"); const web3_utils_1 = require("web3-utils"); const blockchain_1 = require("../blockchain"); const tatum_1 = require("../connector/tatum"); const constants_1 = require("../constants"); const erc1155_abi_1 = __importDefault(require("../contracts/erc1155/erc1155_abi")); const erc1155_bytecode_1 = __importDefault(require("../contracts/erc1155/erc1155_bytecode")); const token_abi_1 = __importDefault(require("../contracts/erc20/token_abi")); const token_abi_2 = __importDefault(require("../contracts/erc20/token_abi")); const token_bytecode_1 = __importDefault(require("../contracts/erc20/token_bytecode")); const erc721_abi_1 = __importDefault(require("../contracts/erc721Cashback/erc721_abi")); const erc721_bytecode_1 = __importDefault(require("../contracts/erc721Cashback/erc721_bytecode")); const erc721Provenance_abi_1 = __importDefault(require("../contracts/erc721Provenance/erc721Provenance_abi")); const erc721Provenance_bytecode_1 = __importDefault(require("../contracts/erc721Provenance/erc721Provenance_bytecode")); const marketplace_1 = require("../contracts/marketplace"); const model_1 = require("../model"); const nft_1 = require("../nft"); const wallet_1 = require("../wallet"); const caver_js_1 = __importDefault(require("caver-js")); const erc721_abi_2 = __importDefault(require("../contracts/erc721General/erc721_abi")); const erc721_bytecode_2 = __importDefault(require("../contracts/erc721General/erc721_bytecode")); /** * Estimate Gas price for the transaction. */ const klayGetGasPriceInWei = async (client) => { return await client.klay.getGasPrice(); }; exports.klayGetGasPriceInWei = klayGetGasPriceInWei; const prepareGeneralTx = async (client, testnet, fromPrivateKey, signatureId, to, amount, nonce, data, gasLimit, gasPrice) => { const tx = { from: 0, to, value: amount ? `0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(amount, 'ether')).toString(16)}` : undefined, data, gas: gasLimit, nonce, gasPrice: gasPrice ? `0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(gasPrice, 'gwei')).toString(16)}` : await exports.klayGetGasPriceInWei(client), }; if (signatureId) { return JSON.stringify(tx); } tx.from = client.klay.accounts.wallet.getAccount(0).address; const estimatedGas = await client.klay.estimateGas({ to, data: data || '', value: tx.value }); tx.gas = gasLimit || estimatedGas; // @ts-ignore return (await client.klay.accounts.signTransaction(tx, fromPrivateKey)).rawTransaction; }; /** * Send Klay transaction to the blockchain. This method broadcasts signed transaction to the blockchain. * This operation is irreversible. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction id of the transaction in the blockchain */ const sendKlaytnTransaction = async (testnet, body, provider) => { return blockchain_1.klaytnBroadcast(await exports.prepareKlaytnSignedTransaction(testnet, body, provider)); }; exports.sendKlaytnTransaction = sendKlaytnTransaction; const prepareKlaytnClient = (testnet, provider, fromPrivateKey) => { const client = new caver_js_1.default(provider || `${process.env.TATUM_API_URL || constants_1.TATUM_API_URL}/v3/blockchain/node/KLAY/${process.env.TATUM_API_KEY}`); if (fromPrivateKey) { client.klay.accounts.wallet.clear(); client.klay.accounts.wallet.add(fromPrivateKey); client.klay.defaultAccount = client.klay.accounts.wallet.getAccount(0).address; } return client; }; exports.prepareKlaytnClient = prepareKlaytnClient; /** * Sign Klay pending transaction from Tatum KMS * @param tx pending transaction from KMS * @param fromPrivateKey private key to sign transaction with. * @param testnet mainnet or testnet version * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const signKlayKMSTransaction = async (tx, fromPrivateKey, testnet, provider) => { if (tx.chain !== model_1.Currency.KLAY) { throw Error('Unsupported chain.'); } const client = exports.prepareKlaytnClient(testnet, provider, fromPrivateKey); const transactionConfig = JSON.parse(tx.serializedTransaction); if (!transactionConfig.gas) { transactionConfig.gas = await client.klay.estimateGas({ to: transactionConfig.to, data: transactionConfig.data }); } if (!transactionConfig.gasPrice || transactionConfig.gasPrice === '0' || transactionConfig.gasPrice === 0 || transactionConfig.gasPrice === '0x0') { transactionConfig.gasPrice = await exports.klayGetGasPriceInWei(client); } transactionConfig.from = client.klay.accounts.wallet.getAccount(0).address; // @ts-ignore return (await client.klay.accounts.signTransaction(transactionConfig, fromPrivateKey)).rawTransaction; }; exports.signKlayKMSTransaction = signKlayKMSTransaction; const getKlayErc20ContractDecimals = async (testnet, contractAddress, provider) => { if (!contractAddress) { throw new Error('Contract address not set.'); } const client = await exports.prepareKlaytnClient(testnet, provider); // @ts-ignore const contract = new client.klay.Contract(token_abi_1.default, contractAddress.trim()); return await contract.methods.decimals().call(); }; exports.getKlayErc20ContractDecimals = getKlayErc20ContractDecimals; /** * Sign Klay generate custodial wallet transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnGenerateCustodialWalletSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.GenerateCustodialAddress); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const { abi, code } = wallet_1.obtainCustodialAddressType(body); // @ts-ignore const contract = new client.klay.Contract(abi); const data = contract.deploy({ data: code, }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnGenerateCustodialWalletSignedTransaction = prepareKlaytnGenerateCustodialWalletSignedTransaction; /** * Sign Klay transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.TransferErc20); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); let data; let to = body.to; if (body.currency === model_1.Currency.KLAY) { data = body.data ? (web3_utils_1.isHex(body.data) ? web3_utils_1.stringToHex(body.data) : web3_utils_1.toHex(body.data)) : undefined; } else { to = constants_1.CONTRACT_ADDRESSES[body.currency]; // @ts-ignore const contract = new client.klay.Contract([constants_1.TRANSFER_METHOD_ABI], to); const digits = new bignumber_js_1.BigNumber(10).pow(constants_1.CONTRACT_DECIMALS[body.currency]); data = contract.methods.transfer(body.to.trim(), `0x${new bignumber_js_1.BigNumber(body.amount).multipliedBy(digits).toString(16)}`).encodeABI(); } return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.to, body.amount, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnSignedTransaction = prepareKlaytnSignedTransaction; /** * Sign Klay store data transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnStoreDataTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.CreateRecord); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const hexData = web3_utils_1.isHex(body.data) ? web3_utils_1.stringToHex(body.data) : web3_utils_1.toHex(body.data); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.to || client.klay.accounts.wallet.getAccount(0).address, undefined, body.nonce, hexData, (_a = body.ethFee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.ethFee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnStoreDataTransaction = prepareKlaytnStoreDataTransaction; /** * Sign Klay mint erc20 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintErc20SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.MintErc20); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const contract = new client.klay.Contract(token_abi_2.default, body.contractAddress.trim().trim()); const digits = new bignumber_js_1.BigNumber(10).pow(await contract.methods.decimals().call()); const data = contract.methods .mint(body.to.trim(), `0x${new bignumber_js_1.BigNumber(body.amount).multipliedBy(digits).toString(16)}`).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnMintErc20SignedTransaction = prepareKlaytnMintErc20SignedTransaction; /** * Sign Klay burn erc20 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnBurnErc20SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.BurnErc20); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const contract = new client.klay.Contract(token_abi_2.default, body.contractAddress.trim().trim()); const digits = new bignumber_js_1.BigNumber(10).pow(await contract.methods.decimals().call()); const data = contract.methods .burn(`0x${new bignumber_js_1.BigNumber(body.amount).multipliedBy(digits).toString(16)}`).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnBurnErc20SignedTransaction = prepareKlaytnBurnErc20SignedTransaction; /** * Sign Klay transfer erc20 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnTransferErc20SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.TransferErc20); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const decimals = new bignumber_js_1.BigNumber(10).pow(body.digits); // @ts-ignore const data = new client.klay.Contract(token_abi_2.default, body.contractAddress.trim().trim()).methods .transfer(body.to.trim(), `0x${new bignumber_js_1.BigNumber(body.amount).multipliedBy(decimals).toString(16)}`).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnTransferErc20SignedTransaction = prepareKlaytnTransferErc20SignedTransaction; /** * Sign Klay deploy erc20 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnDeployErc20SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.DeployErc20); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const contract = new client.klay.Contract(token_abi_2.default); const data = contract.deploy({ data: token_bytecode_1.default, arguments: [ body.name, body.symbol, body.address.trim(), body.digits, `0x${new bignumber_js_1.BigNumber(body.totalCap || body.supply).multipliedBy(new bignumber_js_1.BigNumber(10).pow(body.digits)).toString(16)}`, `0x${new bignumber_js_1.BigNumber(body.supply).multipliedBy(new bignumber_js_1.BigNumber(10).pow(body.digits)).toString(16)}`, ], }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnDeployErc20SignedTransaction = prepareKlaytnDeployErc20SignedTransaction; /** * Sign Klay mint erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthMintErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .mintWithTokenURI(body.to.trim(), body.tokenId, body.url).encodeABI(); if (body.contractAddress) { return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); } throw new Error('Contract address should not be empty!'); }; exports.prepareKlaytnMintErc721SignedTransaction = prepareKlaytnMintErc721SignedTransaction; /** * Sign Klay mint cashback erc721 provenance transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintErc721ProvenanceSignedTransaction = async (testnet, body, provider) => { var _a, _b, _c, _d; await tatum_1.validateBody(body, model_1.EthMintErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const cb = []; const fv = []; if (body.cashbackValues && body.fixedValues && body.authorAddresses) { body.cashbackValues.map(c => cb.push(`0x${new bignumber_js_1.BigNumber(c).multipliedBy(100).toString(16)}`)); body.fixedValues.map(c => fv.push(`0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(c, 'ether')).toString(16)}`)); } if (body.erc20) { // @ts-ignore const data = new client.klay.Contract(erc721Provenance_abi_1.default, body.contractAddress.trim()).methods .mintWithTokenURI(body.to.trim(), body.tokenId, body.url, body.authorAddresses ? body.authorAddresses : [], cb, fv, body.erc20).encodeABI(); if (body.contractAddress) { return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); } throw new Error('Contract address should not be empty!'); } else { // @ts-ignore const data = new client.klay.Contract(erc721Provenance_abi_1.default, body.contractAddress.trim()).methods .mintWithTokenURI(body.to.trim(), body.tokenId, body.url, body.authorAddresses ? body.authorAddresses : [], cb, fv).encodeABI(); if (body.contractAddress) { return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_c = body.fee) === null || _c === void 0 ? void 0 : _c.gasLimit, (_d = body.fee) === null || _d === void 0 ? void 0 : _d.gasPrice); } throw new Error('Contract address should not be empty!'); } }; exports.prepareKlaytnMintErc721ProvenanceSignedTransaction = prepareKlaytnMintErc721ProvenanceSignedTransaction; /** * Sign Klay mint cashback erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintCashbackErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b, _c, _d; await tatum_1.validateBody(body, model_1.EthMintErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const cashbacks = body.cashbackValues; const cb = cashbacks.map(c => `0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(c, 'ether')).toString(16)}`); if (body.erc20) { // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .mintWithCashback(body.to.trim(), body.tokenId, body.url, body.authorAddresses, cb, body.erc20).encodeABI(); if (body.contractAddress) { return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); } throw new Error('Contract address should not be empty!'); } else { // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .mintWithCashback(body.to.trim(), body.tokenId, body.url, body.authorAddresses, cb).encodeABI(); if (body.contractAddress) { return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_c = body.fee) === null || _c === void 0 ? void 0 : _c.gasLimit, (_d = body.fee) === null || _d === void 0 ? void 0 : _d.gasPrice); } throw new Error('Contract address should not be empty!'); } }; exports.prepareKlaytnMintCashbackErc721SignedTransaction = prepareKlaytnMintCashbackErc721SignedTransaction; /** * Sign Klay mint multiple cashback erc721 provenance transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintMultipleErc721ProvenanceSignedTransaction = async (testnet, body, provider) => { var _a, _b, _c, _d; await tatum_1.validateBody(body, model_1.EthMintMultipleErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const cb = []; const fv = []; if (body.cashbackValues && body.fixedValues && body.authorAddresses) { for (let i = 0; i < body.cashbackValues.length; i++) { const cb2 = []; const fv2 = []; for (let j = 0; j < body.cashbackValues[i].length; j++) { cb2.push(`0x${new bignumber_js_1.BigNumber(body.cashbackValues[i][j]).multipliedBy(100).toString(16)}`); fv2.push(`0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(body.fixedValues[i][j], 'ether')).toString(16)}`); } cb.push(cb2); fv.push(fv2); } } if (body.erc20) { // @ts-ignore const data = new client.klay.Contract(erc721Provenance_abi_1.default, body.contractAddress.trim()).methods .mintMultiple(body.to.map(t => t.trim()), body.tokenId, body.url, body.authorAddresses ? body.authorAddresses : [], cb, fv, body.erc20).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); } else { // @ts-ignore const data = new client.klay.Contract(erc721Provenance_abi_1.default, body.contractAddress.trim()).methods .mintMultiple(body.to.map(t => t.trim()), body.tokenId, body.url, body.authorAddresses ? body.authorAddresses : [], cb, fv).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_c = body.fee) === null || _c === void 0 ? void 0 : _c.gasLimit, (_d = body.fee) === null || _d === void 0 ? void 0 : _d.gasPrice); } }; exports.prepareKlaytnMintMultipleErc721ProvenanceSignedTransaction = prepareKlaytnMintMultipleErc721ProvenanceSignedTransaction; /** * Sign Klay mint multiple cashback erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintMultipleCashbackErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b, _c, _d; await tatum_1.validateBody(body, model_1.EthMintMultipleErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const cashbacks = body.cashbackValues; const cb = cashbacks.map(cashback => cashback.map(c => `0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(c, 'ether')).toString(16)}`)); if (body.erc20) { // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .mintMultipleCashback(body.to.map(t => t.trim()), body.tokenId, body.url, body.authorAddresses, cb, body.erc20).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); } else { // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .mintMultipleCashback(body.to.map(t => t.trim()), body.tokenId, body.url, body.authorAddresses, cb).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_c = body.fee) === null || _c === void 0 ? void 0 : _c.gasLimit, (_d = body.fee) === null || _d === void 0 ? void 0 : _d.gasPrice); } }; exports.prepareKlaytnMintMultipleCashbackErc721SignedTransaction = prepareKlaytnMintMultipleCashbackErc721SignedTransaction; /** * Sign Klay mint multiple erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintMultipleErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthMintMultipleErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()) .methods.mintMultiple(body.to.map(t => t.trim()), body.tokenId, body.url).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnMintMultipleErc721SignedTransaction = prepareKlaytnMintMultipleErc721SignedTransaction; /** * Sign Klay burn erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnBurnErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthBurnErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods.burn(body.tokenId).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnBurnErc721SignedTransaction = prepareKlaytnBurnErc721SignedTransaction; /** * Sign Klay transfer erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnTransferErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthTransferErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const contract = new client.klay.Contract(body.provenance ? erc721Provenance_abi_1.default : erc721_abi_1.default, body.contractAddress.trim()); const dataBytes = body.provenance ? Buffer.from(body.provenanceData + '\'\'\'###\'\'\'' + web3_utils_1.toWei(body.tokenPrice, 'ether'), 'utf8') : ''; const data = body.provenance ? contract.methods.safeTransfer(body.to.trim(), body.tokenId, `0x${dataBytes.toString('hex')}`).encodeABI() : contract.methods.safeTransfer(body.to.trim(), body.tokenId).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), body.value, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnTransferErc721SignedTransaction = prepareKlaytnTransferErc721SignedTransaction; /** * Sign Klay update cashback for author erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnUpdateCashbackForAuthorErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.UpdateCashbackErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc721_abi_1.default, body.contractAddress.trim()).methods .updateCashbackForAuthor(body.tokenId, `0x${new bignumber_js_1.BigNumber(web3_utils_1.toWei(body.cashbackValue, 'ether')).toString(16)}`).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnUpdateCashbackForAuthorErc721SignedTransaction = prepareKlaytnUpdateCashbackForAuthorErc721SignedTransaction; /** * Sign Klay deploy erc721 transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnDeployErc721SignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthDeployErc721); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); if (body.provenance && body.cashback) { throw new Error('Only one of provenance or cashback must be present and true.'); } let abi = erc721_abi_2.default; let deployData = erc721_bytecode_2.default; if (body.provenance) { abi = erc721Provenance_abi_1.default; deployData = erc721Provenance_bytecode_1.default; } else if (body.cashback) { abi = erc721_abi_1.default; deployData = erc721_bytecode_1.default; } // @ts-ignore const data = new client.klay.Contract(abi).deploy({ arguments: [body.name, body.symbol, body.publicMint ? body.publicMint : false], data: deployData, }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnDeployErc721SignedTransaction = prepareKlaytnDeployErc721SignedTransaction; /** * Sign Klay generate custodial wallet address transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain, or signatureId in case of Tatum KMS */ const prepareKlaytnDeployMarketplaceListingSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.DeployMarketplaceListing); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(marketplace_1.listing.abi).deploy({ arguments: [body.marketplaceFee, body.feeRecipient], data: marketplace_1.listing.data, }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnDeployMarketplaceListingSignedTransaction = prepareKlaytnDeployMarketplaceListingSignedTransaction; /** * Sign Klay deploy NFT Auction contract transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain, or signatureId in case of Tatum KMS */ const prepareKlaytnDeployAuctionSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.DeployNftAuction); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(marketplace_1.auction.abi).deploy({ arguments: [body.auctionFee, body.feeRecipient], data: marketplace_1.auction.data, }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnDeployAuctionSignedTransaction = prepareKlaytnDeployAuctionSignedTransaction; /** * Sign Klay burn multiple tokens transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnBurnMultiTokenSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthBurnMultiToken); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .burn(body.account.trim(), body.tokenId, body.amount).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnBurnMultiTokenSignedTransaction = prepareKlaytnBurnMultiTokenSignedTransaction; /** * Sign Klay burn multiple tokens batch transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnBurnMultiTokenBatchSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthBurnMultiTokenBatch); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .burnBatch(body.account.trim(), body.tokenId, body.amounts).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnBurnMultiTokenBatchSignedTransaction = prepareKlaytnBurnMultiTokenBatchSignedTransaction; /** * Sign Klay transfer multiple tokens transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnTransferMultiTokenSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.TransferMultiToken); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .safeTransfer(body.to.trim(), body.tokenId, `0x${new bignumber_js_1.BigNumber(body.amount).toString(16)}`, body.data ? body.data : '0x0').encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnTransferMultiTokenSignedTransaction = prepareKlaytnTransferMultiTokenSignedTransaction; /** * Sign Klay batch transfer multiple tokens transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnBatchTransferMultiTokenSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.TransferMultiTokenBatch); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const amts = body.amounts.map(amt => `0x${new bignumber_js_1.BigNumber(amt).toString(16)}`); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .safeBatchTransfer(body.to.trim(), body.tokenId.map(token => token.trim()), amts, body.data ? body.data : '0x0').encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnBatchTransferMultiTokenSignedTransaction = prepareKlaytnBatchTransferMultiTokenSignedTransaction; /** * Sign Klay mint multiple tokens transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintMultiTokenSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.MintMultiToken); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .mint(body.to.trim(), body.tokenId, `0x${new bignumber_js_1.BigNumber(body.amount).toString(16)}`, body.data ? body.data : '0x0').encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnMintMultiTokenSignedTransaction = prepareKlaytnMintMultiTokenSignedTransaction; /** * Sign Klay mint multiple tokens batch transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnMintMultiTokenBatchSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.MintMultiTokenBatch); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); const batchAmounts = body.amounts.map(amts => amts.map(amt => `0x${new bignumber_js_1.BigNumber(amt).toString(16)}`)); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default, body.contractAddress.trim()).methods .mintBatch(body.to, body.tokenId, batchAmounts, body.data ? body.data : '0x0').encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, body.contractAddress.trim(), undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnMintMultiTokenBatchSignedTransaction = prepareKlaytnMintMultiTokenBatchSignedTransaction; /** * Sign Klay deploy multiple tokens transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnDeployMultiTokenSignedTransaction = async (testnet, body, provider) => { var _a, _b; await tatum_1.validateBody(body, model_1.EthDeployMultiToken); const client = await exports.prepareKlaytnClient(testnet, provider, body.fromPrivateKey); // @ts-ignore const data = new client.klay.Contract(erc1155_abi_1.default).deploy({ arguments: [body.uri, body.publicMint ? body.publicMint : false], data: erc1155_bytecode_1.default, }).encodeABI(); return prepareGeneralTx(client, testnet, body.fromPrivateKey, body.signatureId, undefined, undefined, body.nonce, data, (_a = body.fee) === null || _a === void 0 ? void 0 : _a.gasLimit, (_b = body.fee) === null || _b === void 0 ? void 0 : _b.gasPrice); }; exports.prepareKlaytnDeployMultiTokenSignedTransaction = prepareKlaytnDeployMultiTokenSignedTransaction; /** * Sign Klay smart contract write method invocation transaction with private keys locally. Nothing is broadcast to the blockchain. * @param testnet mainnet or testnet version * @param body content of the transaction to broadcast * @param provider url of the Klay Server to connect to. If not set, default public server will be used. * @returns transaction data to be broadcast to blockchain. */ const prepareKlaytnSmartContractWriteMethodInvocation = async (testnet, body, provider) => { await tatum_1.validateBody(body, model_1.SmartContractMethodInvocation); const { fromPrivateKey, fee, params, methodName, methodABI, contractAddress, nonce, amount, signatureId, } = body; const client = await exports.prepareKlaytnClient(testnet, provider, fromPrivateKey); const data = new client.klay.Contract([methodABI]).methods[methodName](...params).encodeABI(); return prepareGeneralTx(client, testnet, fromPrivateKey, signatureId, contractAddress.trim(), amount, nonce, data, fee === null || fee === void 0 ? void 0 : fee.gasLimit, fee === null || fee === void 0 ? void 0 : fee.gasPrice); }; exports.prepareKlaytnSmartContractWriteMethodInvocation = prepareKlaytnSmartContractWriteMethodInvocation; const sendKlaytnSmartContractReadMethodInvocationTransaction = async (testnet, body, provider) => { await tatum_1.validateBody(body, model_1.SmartContractReadMethodInvocation); const { params, methodName, methodABI, contractAddress, } = body; const client = exports.prepareKlaytnClient(testnet, provider); const contract = new client.klay.Contract([methodABI], contractAddress); return { data: await contract.methods[methodName]