This script was last updated for Java Edition 1.16.3 and Bedrock Edition 1.16.100.
Have you seen these pig-like beings in the Nether before? Did you actually know you can trade with them? Well, it's not exactly trading, but rather bartering. You can give them a gold ingot, and they'll give something in return.
Unlike with villagers, you have no control over what the piglin gives you. The piglin choses a random option out of a select list, and gives that to you. In order to start bartering with a piglin, either use the gold ingot on the piglin, or drop it on the ground. The piglin will then grab the item, granted that mob griefing is enabled if you drop it, and admire it for several seconds, after which it will give an item back to you.
You can get many things from piglins, including Soul Speed enchanted books or iron boots, a potion or splash potion of Fire Resistance, ender pearls, nether quartz, both types of obsidian, gravel and blackstone. Because they throw nether quartz, crying obsidian, blackstone and gravel, they became renewable, along with coarse dirt, dirt, mycelium and grass blocks as a result from further processing.
There is only 1 difference in bartering loot between Java Edition and bedrock edition: In java, they can give spectral arrows, but in bedrock those don't exist, so they give normal arrows instead, with the same quantity and chance that they are chosen as in java.
So next time you see a piglin, put on your gold armor, in order to make them not attack you, and bring some gold ingots to barter with them. Just don't try it with the piglin brutes, as they are not interested...