The story
Possibly adapted from bet dollars to buttons and bet dollars to dumplings that appeared in the 1880s, meaning to feel almost certain because the dollars are bet against something nearly worthless and perhaps shaped like the number zero.
Etymology from Wiktionary, CC BY-SA 4.0.