Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ether.js USDT Script to web3.php? #360

Open
skykingisepic opened this issue Sep 29, 2024 · 0 comments
Open

Convert ether.js USDT Script to web3.php? #360

skykingisepic opened this issue Sep 29, 2024 · 0 comments

Comments

@skykingisepic
Copy link

skykingisepic commented Sep 29, 2024

First - sorry for my noobness, with a little initial guidance I should be able to wrap my head around this quickly.

I'm trying to automate sending Membership Commissions pending to each member's USDT Wallet from the Commissions USDT Wallet. globals: $usdtradd, $privkey, and $pendamt for a function that returns $txhash. Will hard code USDT Send Address and contract address. The more I search for examples, the more random results I get, each completely different than the last so I'm getting confused and frustrated. And help or advice greatly appreciated.

I came across web3 snippet to send USDT and was hoping to convert it to php:

var { Web3 } = require("web3");
var provider = "https://mainnet.infura.io/v3/YOUR-API-KEY";
var web3Provider = new Web3.providers.HttpProvider(provider);
var web3 = new Web3(web3Provider);

const USDTAddress = "0xAB0874D3e7Cd256Cd3F1A9480c3b0C01109E2117"; //sender contract address?

// just the transfer() function is sufficient in this case
const ERC20_ABI = [
{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},
];

web3.eth.accounts.wallet.add(SENDER_PRIVATE_KEY); //$pkey

async function run() {
const tokenContract = new Web3.eth.Contract(USDTAddress, ERC20_ABI);

const to = "0x123"; //$usdtaddr
const amount = "1000000"; // $amt: send 1 USDT - don't forget to account for the decimals - 6 for USDT

// invoking the `transfer()` function of the contract
const transaction = await tokenContract.methods.transfer(to, amount).send({from: SENDER_ADDRESS});

} //SENDER_ADDRESS is USDT_ADDRESS (contract address)? Not clear on this value needed here

run();

//end

This is what I have so far for php (not much but struggling to convert the web3.js script)

use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\Contract;

function sendUSDT() {
global $pkey, $usdtadd, $commpend;
$web3 = new Web3(new HttpProvider('https://mainnet.infura.io/v3/API_KEY'));
$eth = $web3->eth;

}

@skykingisepic skykingisepic changed the title No Composer - Files/Folders Required? Convert ether.js USDT Script to php? Convert ether.js USDT Script to php? Sep 29, 2024
@skykingisepic skykingisepic changed the title Convert ether.js USDT Script to php? Convert ether.js USDT Script to web3.php? Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant